Commit 00466cd5 authored by JC Brand's avatar JC Brand

Let the `converse-loaded` event conform to the CustomEvent spec

https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
parent 5a2d361c
...@@ -1670,6 +1670,7 @@ For example: ...@@ -1670,6 +1670,7 @@ For example:
initConverse(shadowRoot) { initConverse(shadowRoot) {
window.addEventListener("converse-loaded", function(event) { window.addEventListener("converse-loaded", function(event) {
const { converse } = event.detail;
converse.initialize({ converse.initialize({
root: shadowRoot, root: shadowRoot,
// Other settings go here... // Other settings go here...
......
...@@ -121,7 +121,6 @@ export default class MessageHistory extends CustomElement { ...@@ -121,7 +121,6 @@ export default class MessageHistory extends CustomElement {
} }
renderMessage (model) { renderMessage (model) {
// XXX: leaky abstraction "is_only_key" from converse-omemo
if (model.get('dangling_retraction') || model.get('is_only_key')) { if (model.get('dangling_retraction') || model.get('is_only_key')) {
return ''; return '';
} }
......
...@@ -578,11 +578,8 @@ converse.plugins.add('converse-chat', { ...@@ -578,11 +578,8 @@ converse.plugins.add('converse-chat', {
}, },
updateMessage (message, attrs) { updateMessage (message, attrs) {
// Overridden in converse-muc and converse-mam
const new_attrs = this.getUpdatedMessageAttributes(message, attrs); const new_attrs = this.getUpdatedMessageAttributes(message, attrs);
if (attrs) { new_attrs && message.save(new_attrs);
message.save(new_attrs);
}
}, },
/** /**
......
...@@ -1655,6 +1655,5 @@ Object.assign(converse, { ...@@ -1655,6 +1655,5 @@ Object.assign(converse, {
* @event converse-loaded * @event converse-loaded
* @example window.addEventListener('converse-loaded', () => converse.initialize()); * @example window.addEventListener('converse-loaded', () => converse.initialize());
*/ */
const ev = new CustomEvent('converse-loaded') const ev = new CustomEvent('converse-loaded', {'detail': { converse }});
ev.converse = converse;
window.dispatchEvent(ev); window.dispatchEvent(ev);
...@@ -1795,7 +1795,6 @@ converse.plugins.add('converse-muc', { ...@@ -1795,7 +1795,6 @@ converse.plugins.add('converse-muc', {
getUpdatedMessageAttributes (message, attrs) { getUpdatedMessageAttributes (message, attrs) {
// Overridden in converse-muc and converse-mam
const new_attrs = _converse.ChatBox.prototype.getUpdatedMessageAttributes.call(this, message, attrs); const new_attrs = _converse.ChatBox.prototype.getUpdatedMessageAttributes.call(this, message, attrs);
if (this.isOwnMessage(attrs)) { if (this.isOwnMessage(attrs)) {
const stanza_id_keys = Object.keys(attrs).filter(k => k.startsWith('stanza_id')); const stanza_id_keys = Object.keys(attrs).filter(k => k.startsWith('stanza_id'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment