Commit 1ddf1032 authored by JC Brand's avatar JC Brand

Register listeners when occupant is added to a message

parent d49b630b
...@@ -107,17 +107,15 @@ converse.plugins.add('converse-message-view', { ...@@ -107,17 +107,15 @@ converse.plugins.add('converse-message-view', {
}); });
} }
if (this.model.occupant) { this.model.occupant && this.addOccupantListeners();
this.listenTo(this.model.occupant, 'change:affiliation', this.debouncedRender);
this.listenTo(this.model.occupant, 'change:hats', this.debouncedRender);
this.listenTo(this.model.occupant, 'change:role', this.debouncedRender);
this.debouncedRender();
}
this.listenTo(this.model, 'change', this.onChanged); this.listenTo(this.model, 'change', this.onChanged);
this.listenTo(this.model, 'destroy', this.fadeOut); this.listenTo(this.model, 'destroy', this.fadeOut);
this.listenTo(this.model, 'occupantAdded', this.debouncedRender); this.listenTo(this.model, 'occupantAdded', () => {
this.addOccupantListeners();
this.debouncedRender();
});
this.listenTo(this.model, 'vcard:change', this.debouncedRender); this.listenTo(this.model, 'vcard:change', this.debouncedRender);
this.debouncedRender();
}, },
async render () { async render () {
...@@ -156,6 +154,12 @@ converse.plugins.add('converse-message-view', { ...@@ -156,6 +154,12 @@ converse.plugins.add('converse-message-view', {
} }
}, },
addOccupantListeners () {
this.listenTo(this.model.occupant, 'change:affiliation', this.debouncedRender);
this.listenTo(this.model.occupant, 'change:hats', this.debouncedRender);
this.listenTo(this.model.occupant, 'change:role', this.debouncedRender);
},
fadeOut () { fadeOut () {
if (api.settings.get('animate')) { if (api.settings.get('animate')) {
setTimeout(() => this.remove(), 600); setTimeout(() => this.remove(), 600);
......
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