Commit cc91f375 authored by JC Brand's avatar JC Brand

Add `listenTo` instead of `on` to avoid memory leaks

parent d9c1bbf9
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
This means that all your assets need to be served at `/dist`. If you need to set a This means that all your assets need to be served at `/dist`. If you need to set a
different path, you'll need to set `publicPath` in `webpack.config.js` to different path, you'll need to set `publicPath` in `webpack.config.js` to
your preferred path and then rebuild all assets (e.g. `make dist`). your preferred path and then rebuild all assets (e.g. `make dist`).
- Use `listenTo` to avoid memory leaks when views get removed.
## 5.0.1 (2019-08-14) ## 5.0.1 (2019-08-14)
......
...@@ -246,11 +246,11 @@ converse.plugins.add('converse-bookmark-views', { ...@@ -246,11 +246,11 @@ converse.plugins.add('converse-bookmark-views', {
initialize () { initialize () {
OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
this.model.on('add', this.showOrHide, this); this.listenTo(this.model, 'add', this.showOrHide);
this.model.on('remove', this.showOrHide, this); this.listenTo(this.model, 'remove', this.showOrHide);
_converse.chatboxes.on('add', this.renderBookmarkListElement, this); this.listenTo(_converse.chatboxes, 'add', this.renderBookmarkListElement);
_converse.chatboxes.on('remove', this.renderBookmarkListElement, this); this.listenTo(_converse.chatboxes, 'remove', this.renderBookmarkListElement);
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = `converse.room-bookmarks${_converse.bare_jid}-list-model`; id = `converse.room-bookmarks${_converse.bare_jid}-list-model`;
......
...@@ -111,7 +111,7 @@ converse.plugins.add('converse-chatboxviews', { ...@@ -111,7 +111,7 @@ converse.plugins.add('converse-chatboxviews', {
}, },
initialize () { initialize () {
this.model.on("destroy", this.removeChat, this); this.listenTo(this.model, "destroy", this.removeChat)
const bg = document.getElementById('conversejs-bg'); const bg = document.getElementById('conversejs-bg');
if (bg && !bg.innerHTML.trim()) { if (bg && !bg.innerHTML.trim()) {
bg.innerHTML = tpl_background_logo(); bg.innerHTML = tpl_background_logo();
......
...@@ -85,15 +85,15 @@ converse.plugins.add('converse-chatview', { ...@@ -85,15 +85,15 @@ converse.plugins.add('converse-chatview', {
_converse.ChatBoxHeading = _converse.ViewWithAvatar.extend({ _converse.ChatBoxHeading = _converse.ViewWithAvatar.extend({
initialize () { initialize () {
this.model.on('change:status', this.onStatusMessageChanged, this); this.listenTo(this.model, 'change:status', this.onStatusMessageChanged);
this.debouncedRender = _.debounce(this.render, 50); this.debouncedRender = _.debounce(this.render, 50);
if (this.model.vcard) { if (this.model.vcard) {
this.model.vcard.on('change', this.debouncedRender, this); this.listenTo(this.model.vcard, 'change', this.debouncedRender);
} }
if (this.model.rosterContactAdded) { if (this.model.rosterContactAdded) {
this.model.rosterContactAdded.then(() => { this.model.rosterContactAdded.then(() => {
this.model.contact.on('change:nickname', this.debouncedRender, this); this.listenTo(this.model.contact, 'change:nickname', this.debouncedRender);
this.debouncedRender(); this.debouncedRender();
}); });
} }
...@@ -145,7 +145,7 @@ converse.plugins.add('converse-chatview', { ...@@ -145,7 +145,7 @@ converse.plugins.add('converse-chatview', {
initialize () { initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments); _converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.rosterContactAdded.then(() => this.registerContactEventHandlers()); this.model.rosterContactAdded.then(() => this.registerContactEventHandlers());
this.model.on('change', this.render, this); this.listenTo(this.model, 'change', this.render);
this.registerContactEventHandlers(); this.registerContactEventHandlers();
/** /**
* Triggered once the _converse.UserDetailsModal has been initialized * Triggered once the _converse.UserDetailsModal has been initialized
...@@ -175,8 +175,8 @@ converse.plugins.add('converse-chatview', { ...@@ -175,8 +175,8 @@ converse.plugins.add('converse-chatview', {
registerContactEventHandlers () { registerContactEventHandlers () {
if (this.model.contact !== undefined) { if (this.model.contact !== undefined) {
this.model.contact.on('change', this.render, this); this.listenTo(this.model.contact, 'change', this.render);
this.model.contact.vcard.on('change', this.render, this); this.listenTo(this.model.contact.vcard, 'change', this.render);
this.model.contact.on('destroy', () => { this.model.contact.on('destroy', () => {
delete this.model.contact; delete this.model.contact;
this.render(); this.render();
...@@ -257,17 +257,17 @@ converse.plugins.add('converse-chatview', { ...@@ -257,17 +257,17 @@ converse.plugins.add('converse-chatview', {
async initialize () { async initialize () {
this.initDebounced(); this.initDebounced();
this.model.messages.on('add', this.onMessageAdded, this); this.listenTo(this.model.messages, 'add', this.onMessageAdded);
this.model.messages.on('rendered', this.scrollDown, this); this.listenTo(this.model.messages, 'rendered', this.scrollDown);
this.model.messages.on('reset', () => { this.model.messages.on('reset', () => {
this.content.innerHTML = ''; this.content.innerHTML = '';
this.removeAll(); this.removeAll();
}); });
this.model.on('show', this.show, this); this.listenTo(this.model, 'show', this.show);
this.model.on('destroy', this.remove, this); this.listenTo(this.model, 'destroy', this.remove);
this.model.presence.on('change:show', this.onPresenceChanged, this); this.listenTo(this.model.presence, 'change:show', this.onPresenceChanged);
this.render(); this.render();
await this.updateAfterMessagesFetched(); await this.updateAfterMessagesFetched();
...@@ -429,7 +429,7 @@ converse.plugins.add('converse-chatview', { ...@@ -429,7 +429,7 @@ converse.plugins.add('converse-chatview', {
this.heading.chatview = this; this.heading.chatview = this;
if (this.model.contact !== undefined) { if (this.model.contact !== undefined) {
this.model.contact.on('destroy', this.heading.render, this); this.listenTo(this.model.contact, 'destroy', this.heading.render);
} }
const flyout = this.el.querySelector('.flyout'); const flyout = this.el.querySelector('.flyout');
flyout.insertBefore(this.heading.el, flyout.querySelector('.chat-body')); flyout.insertBefore(this.heading.el, flyout.querySelector('.chat-body'));
......
...@@ -189,11 +189,11 @@ converse.plugins.add('converse-controlbox', { ...@@ -189,11 +189,11 @@ converse.plugins.add('converse-controlbox', {
} }
_converse.controlboxtoggle.el.insertAdjacentElement('afterend', this.el); _converse.controlboxtoggle.el.insertAdjacentElement('afterend', this.el);
this.model.on('change:connected', this.onConnected, this); this.listenTo(this.model, 'change:connected', this.onConnected)
this.model.on('destroy', this.hide, this); this.listenTo(this.model, 'destroy', this.hide)
this.model.on('hide', this.hide, this); this.listenTo(this.model, 'hide', this.hide)
this.model.on('show', this.show, this); this.listenTo(this.model, 'show', this.show)
this.model.on('change:closed', this.ensureClosedState, this); this.listenTo(this.model, 'change:closed', this.ensureClosedState)
this.render(); this.render();
/** /**
* Triggered when the _converse.ControlBoxView has been initialized and therefore * Triggered when the _converse.ControlBoxView has been initialized and therefore
...@@ -366,7 +366,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -366,7 +366,7 @@ converse.plugins.add('converse-controlbox', {
}, },
initialize (cfg) { initialize (cfg) {
this.model.on('change', this.render, this); this.listenTo(this.model, 'change', this.render)
this.listenTo(_converse.connfeedback, 'change', this.render); this.listenTo(_converse.connfeedback, 'change', this.render);
this.render(); this.render();
}, },
......
...@@ -150,7 +150,7 @@ converse.plugins.add('converse-dragresize', { ...@@ -150,7 +150,7 @@ converse.plugins.add('converse-dragresize', {
const view = this; const view = this;
const debouncedSetDimensions = _.debounce(() => view.setDimensions()); const debouncedSetDimensions = _.debounce(() => view.setDimensions());
window.addEventListener('resize', view.debouncedSetDimensions) window.addEventListener('resize', view.debouncedSetDimensions)
this.model.on('destroy', () => window.removeEventListener('resize', debouncedSetDimensions)); this.listenTo(this.model, 'destroy', () => window.removeEventListener('resize', debouncedSetDimensions));
// Determine and store the default box size. // Determine and store the default box size.
// We need this information for the drag-resizing feature. // We need this information for the drag-resizing feature.
......
...@@ -149,9 +149,9 @@ converse.plugins.add('converse-emoji-views', { ...@@ -149,9 +149,9 @@ converse.plugins.add('converse-emoji-views', {
async initialize () { async initialize () {
this.search_results = []; this.search_results = [];
this.debouncedFilter = debounce(input => this.filter(input.value), 150); this.debouncedFilter = debounce(input => this.filter(input.value), 150);
this.model.on('change:query', this.render, this); this.listenTo(this.model, 'change:query', this.render)
this.model.on('change:current_skintone', this.render, this); this.listenTo(this.model, 'change:current_skintone', this.render)
this.model.on('change:current_category', this.render, this); this.listenTo(this.model, 'change:current_category', this.render)
await _converse.api.waitUntil('emojisInitialized'); await _converse.api.waitUntil('emojisInitialized');
this.render(); this.render();
_converse.api.trigger('emojiPickerViewInitialized'); _converse.api.trigger('emojiPickerViewInitialized');
......
...@@ -85,10 +85,10 @@ converse.plugins.add('converse-headline', { ...@@ -85,10 +85,10 @@ converse.plugins.add('converse-headline', {
this.initDebounced(); this.initDebounced();
this.model.disable_mam = true; // Don't do MAM queries for this box this.model.disable_mam = true; // Don't do MAM queries for this box
this.model.messages.on('add', this.onMessageAdded, this); this.listenTo(this.model.messages, 'add', this.onMessageAdded);
this.model.on('show', this.show, this); this.listenTo(this.model, 'show', this.show);
this.model.on('destroy', this.hide, this); this.listenTo(this.model, 'destroy', this.hide);
this.model.on('change:minimized', this.onMinimizedChanged, this); this.listenTo(this.model, 'change:minimized', this.onMinimizedChanged);
this.render().insertHeading() this.render().insertHeading()
this.updateAfterMessagesFetched(); this.updateAfterMessagesFetched();
......
...@@ -102,24 +102,24 @@ converse.plugins.add('converse-message-view', { ...@@ -102,24 +102,24 @@ converse.plugins.add('converse-message-view', {
}, 50); }, 50);
if (this.model.vcard) { if (this.model.vcard) {
this.model.vcard.on('change', this.debouncedRender, this); this.listenTo(this.model.vcard, 'change', this.debouncedRender);
} }
if (this.model.rosterContactAdded) { if (this.model.rosterContactAdded) {
this.model.rosterContactAdded.then(() => { this.model.rosterContactAdded.then(() => {
this.model.contact.on('change:nickname', this.debouncedRender, this); this.listenTo(this.model.contact, 'change:nickname', this.debouncedRender);
this.debouncedRender(); this.debouncedRender();
}); });
} }
if (this.model.occupant) { if (this.model.occupant) {
this.model.occupant.on('change:role', this.debouncedRender, this); this.listenTo(this.model.occupant, 'change:role', this.debouncedRender);
this.model.occupant.on('change:affiliation', this.debouncedRender, this); this.listenTo(this.model.occupant, 'change:affiliation', this.debouncedRender);
this.debouncedRender(); this.debouncedRender();
} }
this.model.on('change', this.onChanged, this); this.listenTo(this.model, 'change', this.onChanged);
this.model.on('destroy', this.fadeOut, this); this.listenTo(this.model, 'destroy', this.fadeOut);
}, },
async render () { async render () {
......
...@@ -74,7 +74,7 @@ converse.plugins.add('converse-minimize', { ...@@ -74,7 +74,7 @@ converse.plugins.add('converse-minimize', {
}, },
initialize () { initialize () {
this.model.on('change:minimized', this.onMinimizedChanged, this); this.listenTo(this.model, 'change:minimized', this.onMinimizedChanged)
return this.__super__.initialize.apply(this, arguments); return this.__super__.initialize.apply(this, arguments);
}, },
...@@ -135,7 +135,7 @@ converse.plugins.add('converse-minimize', { ...@@ -135,7 +135,7 @@ converse.plugins.add('converse-minimize', {
}, },
initialize () { initialize () {
this.model.on('change:minimized', this.onMinimizedChanged, this); this.listenTo(this.model, 'change:minimized', this.onMinimizedChanged)
const result = this.__super__.initialize.apply(this, arguments); const result = this.__super__.initialize.apply(this, arguments);
if (this.model.get('minimized')) { if (this.model.get('minimized')) {
this.hide(); this.hide();
...@@ -384,11 +384,11 @@ converse.plugins.add('converse-minimize', { ...@@ -384,11 +384,11 @@ converse.plugins.add('converse-minimize', {
}, },
initialize () { initialize () {
this.model.on('change:num_unread', this.render, this); this.listenTo(this.model, 'change:num_unread', this.render)
this.model.on('change:name', this.render, this); this.listenTo(this.model, 'change:name', this.render)
this.model.on('change:fullname', this.render, this); this.listenTo(this.model, 'change:fullname', this.render)
this.model.on('change:jid', this.render, this); this.listenTo(this.model, 'change:jid', this.render)
this.model.on('destroy', this.remove, this); this.listenTo(this.model, 'destroy', this.remove)
}, },
render () { render () {
...@@ -438,10 +438,10 @@ converse.plugins.add('converse-minimize', { ...@@ -438,10 +438,10 @@ converse.plugins.add('converse-minimize', {
this.render(); this.render();
this.initToggle(); this.initToggle();
this.addMultipleChats(this.model.where({'minimized': true})); this.addMultipleChats(this.model.where({'minimized': true}));
this.model.on("add", this.onChanged, this); this.listenTo(this.model, "add", this.onChanged)
this.model.on("destroy", this.removeChat, this); this.listenTo(this.model, "destroy", this.removeChat)
this.model.on("change:minimized", this.onChanged, this); this.listenTo(this.model, "change:minimized", this.onChanged)
this.model.on('change:num_unread', this.updateUnreadMessagesCounter, this); this.listenTo(this.model, 'change:num_unread', this.updateUnreadMessagesCounter)
}, },
render () { render () {
...@@ -535,8 +535,8 @@ converse.plugins.add('converse-minimize', { ...@@ -535,8 +535,8 @@ converse.plugins.add('converse-minimize', {
}, },
initialize () { initialize () {
this.model.on('change:num_minimized', this.render, this); this.listenTo(this.model, 'change:num_minimized', this.render)
this.model.on('change:num_unread', this.render, this); this.listenTo(this.model, 'change:num_unread', this.render)
this.flyout = this.el.parentElement.querySelector('.minimized-chats-flyout'); this.flyout = this.el.parentElement.querySelector('.minimized-chats-flyout');
}, },
......
...@@ -82,7 +82,7 @@ converse.plugins.add('converse-modal', { ...@@ -82,7 +82,7 @@ converse.plugins.add('converse-modal', {
initialize () { initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments); _converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change', this.render, this); this.listenTo(this.model, 'change', this.render)
}, },
toHTML () { toHTML () {
......
...@@ -223,11 +223,11 @@ converse.plugins.add('converse-muc-views', { ...@@ -223,11 +223,11 @@ converse.plugins.add('converse-muc-views', {
this.chatroomview = attrs.chatroomview; this.chatroomview = attrs.chatroomview;
_converse.BootstrapModal.prototype.initialize.apply(this, arguments); _converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change:role', () => { this.listenTo(this.model, 'change:role', () => {
this.users_with_role = this.getUsersWithRole(); this.users_with_role = this.getUsersWithRole();
this.render(); this.render();
}); });
this.model.on('change:affiliation', async () => { this.listenTo(this.model, 'change:affiliation', async () => {
this.loading_users_with_affiliation = true; this.loading_users_with_affiliation = true;
this.users_with_affiliation = null; this.users_with_affiliation = null;
this.render(); this.render();
...@@ -384,7 +384,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -384,7 +384,7 @@ converse.plugins.add('converse-muc-views', {
if (_converse.muc_domain && !this.model.get('muc_domain')) { if (_converse.muc_domain && !this.model.get('muc_domain')) {
this.model.save('muc_domain', _converse.muc_domain); this.model.save('muc_domain', _converse.muc_domain);
} }
this.model.on('change:muc_domain', this.onDomainChange, this); this.listenTo(this.model, 'change:muc_domain', this.onDomainChange);
}, },
toHTML () { toHTML () {
...@@ -511,7 +511,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -511,7 +511,7 @@ converse.plugins.add('converse-muc-views', {
initialize () { initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments); _converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change:muc_domain', this.render, this); this.listenTo(this.model, 'change:muc_domain', this.render);
}, },
toHTML () { toHTML () {
...@@ -577,9 +577,9 @@ converse.plugins.add('converse-muc-views', { ...@@ -577,9 +577,9 @@ converse.plugins.add('converse-muc-views', {
initialize () { initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments); _converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change', this.render, this); this.listenTo(this.model, 'change', this.render);
this.model.occupants.on('add', this.render, this); this.listenTo(this.model.occupants, 'add', this.render);
this.model.occupants.on('change', this.render, this); this.listenTo(this.model.occupants, 'change', this.render);
}, },
toHTML () { toHTML () {
...@@ -636,28 +636,28 @@ converse.plugins.add('converse-muc-views', { ...@@ -636,28 +636,28 @@ converse.plugins.add('converse-muc-views', {
initialize () { initialize () {
this.initDebounced(); this.initDebounced();
this.model.messages.on('add', this.onMessageAdded, this); this.listenTo(this.model.messages, 'add', this.onMessageAdded);
this.model.messages.on('rendered', this.scrollDown, this); this.listenTo(this.model.messages, 'rendered', this.scrollDown);
this.model.messages.on('reset', () => { this.model.messages.on('reset', () => {
this.content.innerHTML = ''; this.content.innerHTML = '';
this.removeAll(); this.removeAll();
}); });
this.model.on('change', this.renderHeading, this); this.listenTo(this.model, 'change', this.renderHeading);
this.model.on('change:connection_status', this.onConnectionStatusChanged, this); this.listenTo(this.model, 'change:connection_status', this.onConnectionStatusChanged);
this.model.on('change:hidden_occupants', this.updateOccupantsToggle, this); this.listenTo(this.model, 'change:hidden_occupants', this.updateOccupantsToggle);
this.model.on('change:subject', this.setChatRoomSubject, this); this.listenTo(this.model, 'change:subject', this.setChatRoomSubject);
this.model.on('configurationNeeded', this.getAndRenderConfigurationForm, this); this.listenTo(this.model, 'configurationNeeded', this.getAndRenderConfigurationForm);
this.model.on('destroy', this.hide, this); this.listenTo(this.model, 'destroy', this.hide);
this.model.on('show', this.show, this); this.listenTo(this.model, 'show', this.show);
this.model.features.on('change:moderated', this.renderBottomPanel, this); this.listenTo(this.model.features, 'change:moderated', this.renderBottomPanel);
this.model.occupants.on('add', this.onOccupantAdded, this); this.listenTo(this.model.occupants, 'add', this.onOccupantAdded);
this.model.occupants.on('remove', this.onOccupantRemoved, this); this.listenTo(this.model.occupants, 'remove', this.onOccupantRemoved);
this.model.occupants.on('change:show', this.showJoinOrLeaveNotification, this); this.listenTo(this.model.occupants, 'change:show', this.showJoinOrLeaveNotification);
this.model.occupants.on('change:role', this.onOccupantRoleChanged, this); this.listenTo(this.model.occupants, 'change:role', this.onOccupantRoleChanged);
this.model.occupants.on('change:affiliation', this.onOccupantAffiliationChanged, this); this.listenTo(this.model.occupants, 'change:affiliation', this.onOccupantAffiliationChanged);
this.render(); this.render();
this.updateAfterMessagesFetched(); this.updateAfterMessagesFetched();
...@@ -1734,8 +1734,8 @@ converse.plugins.add('converse-muc-views', { ...@@ -1734,8 +1734,8 @@ converse.plugins.add('converse-muc-views', {
initialize (attrs) { initialize (attrs) {
this.chatroomview = attrs.chatroomview; this.chatroomview = attrs.chatroomview;
this.chatroomview.model.features.on('change:passwordprotected', this.render, this); this.listenTo(this.chatroomview.model.features, 'change:passwordprotected', this.render);
this.chatroomview.model.features.on('change:config_stanza', this.render, this); this.listenTo(this.chatroomview.model.features, 'change:config_stanza', this.render);
this.render(); this.render();
}, },
...@@ -1780,7 +1780,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1780,7 +1780,7 @@ converse.plugins.add('converse-muc-views', {
initialize (attrs) { initialize (attrs) {
this.chatroomview = attrs.chatroomview; this.chatroomview = attrs.chatroomview;
this.model.on('change:validation_message', this.render, this); this.listenTo(this.model, 'change:validation_message', this.render);
this.render(); this.render();
}, },
...@@ -1813,7 +1813,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1813,7 +1813,7 @@ converse.plugins.add('converse-muc-views', {
initialize (attrs) { initialize (attrs) {
this.chatroomview = attrs.chatroomview; this.chatroomview = attrs.chatroomview;
this.model.on('change:validation_message', this.render, this); this.listenTo(this.model, 'change:validation_message', this.render);
this.render(); this.render();
}, },
...@@ -1853,7 +1853,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1853,7 +1853,7 @@ converse.plugins.add('converse-muc-views', {
_converse.ChatRoomOccupantView = Backbone.VDOMView.extend({ _converse.ChatRoomOccupantView = Backbone.VDOMView.extend({
tagName: 'li', tagName: 'li',
initialize () { initialize () {
this.model.on('change', this.render, this); this.listenTo(this.model, 'change', this.render);
}, },
toHTML () { toHTML () {
...@@ -1895,13 +1895,13 @@ converse.plugins.add('converse-muc-views', { ...@@ -1895,13 +1895,13 @@ converse.plugins.add('converse-muc-views', {
async initialize () { async initialize () {
OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
this.model.on('add', this.maybeRenderInviteWidget, this); this.listenTo(this.model, 'add', this.maybeRenderInviteWidget);
this.model.on('change:affiliation', this.maybeRenderInviteWidget, this); this.listenTo(this.model, 'change:affiliation', this.maybeRenderInviteWidget);
this.chatroomview = this.model.chatroomview; this.chatroomview = this.model.chatroomview;
this.chatroomview.model.features.on('change', this.renderRoomFeatures, this); this.listenTo(this.chatroomview.model.features, 'change', this.renderRoomFeatures);
this.chatroomview.model.features.on('change:open', this.renderInviteWidget, this); this.listenTo(this.chatroomview.model.features, 'change:open', this.renderInviteWidget);
this.chatroomview.model.on('change:hidden_occupants', this.setVisibility, this); this.listenTo(this.chatroomview.model, 'change:hidden_occupants', this.setVisibility);
this.render(); this.render();
await this.model.fetched; await this.model.fetched;
this.sortAndPositionAllItems(); this.sortAndPositionAllItems();
......
...@@ -89,11 +89,11 @@ converse.plugins.add('converse-omemo', { ...@@ -89,11 +89,11 @@ converse.plugins.add('converse-omemo', {
const { _converse } = this.__super__; const { _converse } = this.__super__;
this.debouncedRender = _.debounce(this.render, 50); this.debouncedRender = _.debounce(this.render, 50);
this.devicelist = _converse.devicelists.get(_converse.bare_jid); this.devicelist = _converse.devicelists.get(_converse.bare_jid);
this.devicelist.devices.on('change:bundle', this.debouncedRender, this); this.listenTo(this.devicelist.devices, 'change:bundle', this.debouncedRender);
this.devicelist.devices.on('reset', this.debouncedRender, this); this.listenTo(this.devicelist.devices, 'reset', this.debouncedRender);
this.devicelist.devices.on('reset', this.debouncedRender, this); this.listenTo(this.devicelist.devices, 'reset', this.debouncedRender);
this.devicelist.devices.on('remove', this.debouncedRender, this); this.listenTo(this.devicelist.devices, 'remove', this.debouncedRender);
this.devicelist.devices.on('add', this.debouncedRender, this); this.listenTo(this.devicelist.devices, 'add', this.debouncedRender);
return this.__super__.initialize.apply(this, arguments); return this.__super__.initialize.apply(this, arguments);
}, },
...@@ -159,11 +159,11 @@ converse.plugins.add('converse-omemo', { ...@@ -159,11 +159,11 @@ converse.plugins.add('converse-omemo', {
const { _converse } = this.__super__; const { _converse } = this.__super__;
const jid = this.model.get('jid'); const jid = this.model.get('jid');
this.devicelist = _converse.devicelists.getDeviceList(jid); this.devicelist = _converse.devicelists.getDeviceList(jid);
this.devicelist.devices.on('change:bundle', this.render, this); this.listenTo(this.devicelist.devices, 'change:bundle', this.render);
this.devicelist.devices.on('change:trusted', this.render, this); this.listenTo(this.devicelist.devices, 'change:trusted', this.render);
this.devicelist.devices.on('remove', this.render, this); this.listenTo(this.devicelist.devices, 'remove', this.render);
this.devicelist.devices.on('add', this.render, this); this.listenTo(this.devicelist.devices, 'add', this.render);
this.devicelist.devices.on('reset', this.render, this); this.listenTo(this.devicelist.devices, 'reset', this.render);
return this.__super__.initialize.apply(this, arguments); return this.__super__.initialize.apply(this, arguments);
}, },
...@@ -217,8 +217,8 @@ converse.plugins.add('converse-omemo', { ...@@ -217,8 +217,8 @@ converse.plugins.add('converse-omemo', {
initialize () { initialize () {
this.__super__.initialize.apply(this, arguments); this.__super__.initialize.apply(this, arguments);
this.model.on('change:omemo_active', this.renderOMEMOToolbarButton, this); this.listenTo(this.model, 'change:omemo_active', this.renderOMEMOToolbarButton);
this.model.on('change:omemo_supported', this.onOMEMOSupportedDetermined, this); this.listenTo(this.model, 'change:omemo_supported', this.onOMEMOSupportedDetermined);
}, },
showMessage (message) { showMessage (message) {
...@@ -236,8 +236,8 @@ converse.plugins.add('converse-omemo', { ...@@ -236,8 +236,8 @@ converse.plugins.add('converse-omemo', {
initialize () { initialize () {
this.__super__.initialize.apply(this, arguments); this.__super__.initialize.apply(this, arguments);
this.model.on('change:omemo_active', this.renderOMEMOToolbarButton, this); this.listenTo(this.model, 'change:omemo_active', this.renderOMEMOToolbarButton);
this.model.on('change:omemo_supported', this.onOMEMOSupportedDetermined, this); this.listenTo(this.model, 'change:omemo_supported', this.onOMEMOSupportedDetermined);
} }
} }
}, },
......
...@@ -46,7 +46,7 @@ converse.plugins.add('converse-profile', { ...@@ -46,7 +46,7 @@ converse.plugins.add('converse-profile', {
}, },
initialize () { initialize () {
this.model.on('change', this.render, this); this.listenTo(this.model, 'change', this.render);
_converse.BootstrapModal.prototype.initialize.apply(this, arguments); _converse.BootstrapModal.prototype.initialize.apply(this, arguments);
/** /**
* Triggered when the _converse.ProfileModal has been created and initialized. * Triggered when the _converse.ProfileModal has been created and initialized.
...@@ -234,8 +234,8 @@ converse.plugins.add('converse-profile', { ...@@ -234,8 +234,8 @@ converse.plugins.add('converse-profile', {
}, },
initialize () { initialize () {
this.model.on("change", this.render, this); this.listenTo(this.model, "change", this.render);
this.model.vcard.on("change", this.render, this); this.listenTo(this.model.vcard, "change", this.render);
}, },
toHTML () { toHTML () {
......
...@@ -103,13 +103,13 @@ converse.plugins.add('converse-roomslist', { ...@@ -103,13 +103,13 @@ converse.plugins.add('converse-roomslist', {
}, },
initialize () { initialize () {
this.model.on('destroy', this.remove, this); this.listenTo(this.model, 'destroy', this.remove)
this.model.on('remove', this.remove, this); this.listenTo(this.model, 'remove', this.remove)
this.model.on('change:bookmarked', this.render, this); this.listenTo(this.model, 'change:bookmarked', this.render)
this.model.on('change:hidden', this.render, this); this.listenTo(this.model, 'change:hidden', this.render)
this.model.on('change:name', this.render, this); this.listenTo(this.model, 'change:name', this.render)
this.model.on('change:num_unread', this.render, this); this.listenTo(this.model, 'change:num_unread', this.render)
this.model.on('change:num_unread_general', this.render, this); this.listenTo(this.model, 'change:num_unread_general', this.render)
}, },
toHTML () { toHTML () {
...@@ -168,8 +168,8 @@ converse.plugins.add('converse-roomslist', { ...@@ -168,8 +168,8 @@ converse.plugins.add('converse-roomslist', {
initialize () { initialize () {
OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
this.model.on('add', this.showOrHide, this); this.listenTo(this.model, 'add', this.showOrHide)
this.model.on('remove', this.showOrHide, this); this.listenTo(this.model, 'remove', this.showOrHide)
const storage = _converse.config.get('storage'), const storage = _converse.config.get('storage'),
id = `converse.roomslist${_converse.bare_jid}`; id = `converse.roomslist${_converse.bare_jid}`;
......
...@@ -68,7 +68,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -68,7 +68,7 @@ converse.plugins.add('converse-rosterview', {
initialize () { initialize () {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments); _converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change', this.render, this); this.listenTo(this.model, 'change', this.render);
}, },
toHTML () { toHTML () {
...@@ -220,8 +220,8 @@ converse.plugins.add('converse-rosterview', { ...@@ -220,8 +220,8 @@ converse.plugins.add('converse-rosterview', {
}, },
initialize () { initialize () {
this.model.on('change:filter_type', this.render, this); this.listenTo(this.model, 'change:filter_type', this.render);
this.model.on('change:filter_text', this.render, this); this.listenTo(this.model, 'change:filter_text', this.render);
}, },
toHTML () { toHTML () {
...@@ -341,14 +341,14 @@ converse.plugins.add('converse-rosterview', { ...@@ -341,14 +341,14 @@ converse.plugins.add('converse-rosterview', {
}, },
initialize () { initialize () {
this.model.on("change", this.render, this); this.listenTo(this.model, "change", this.render);
this.model.on("highlight", this.highlight, this); this.listenTo(this.model, "highlight", this.highlight);
this.model.on("destroy", this.remove, this); this.listenTo(this.model, "destroy", this.remove);
this.model.on("open", this.openChat, this); this.listenTo(this.model, "open", this.openChat);
this.model.on("remove", this.remove, this); this.listenTo(this.model, "remove", this.remove);
this.model.presence.on("change:show", this.render, this); this.listenTo(this.model.presence, "change:show", this.render);
this.model.vcard.on('change:fullname', this.render, this); this.listenTo(this.model.vcard, 'change:fullname', this.render);
}, },
render () { render () {
...@@ -551,10 +551,10 @@ converse.plugins.add('converse-rosterview', { ...@@ -551,10 +551,10 @@ converse.plugins.add('converse-rosterview', {
initialize () { initialize () {
OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
this.model.contacts.on("change:subscription", this.onContactSubscriptionChange, this); this.listenTo(this.model.contacts, "change:subscription", this.onContactSubscriptionChange);
this.model.contacts.on("change:requesting", this.onContactRequestChange, this); this.listenTo(this.model.contacts, "change:requesting", this.onContactRequestChange);
this.model.contacts.on("remove", this.onRemove, this); this.listenTo(this.model.contacts, "remove", this.onRemove);
_converse.roster.on('change:groups', this.onContactGroupChange, this); this.listenTo(_converse.roster, 'change:groups', this.onContactGroupChange);
// This event gets triggered once *all* contacts (i.e. not // This event gets triggered once *all* contacts (i.e. not
// just this group's) have been fetched from browser // just this group's) have been fetched from browser
...@@ -748,17 +748,17 @@ converse.plugins.add('converse-rosterview', { ...@@ -748,17 +748,17 @@ converse.plugins.add('converse-rosterview', {
initialize () { initialize () {
OrderedListView.prototype.initialize.apply(this, arguments); OrderedListView.prototype.initialize.apply(this, arguments);
_converse.roster.on("add", this.onContactAdded, this); this.listenTo(_converse.roster, "add", this.onContactAdded);
_converse.roster.on('change:groups', this.onContactAdded, this); this.listenTo(_converse.roster, 'change:groups', this.onContactAdded);
_converse.roster.on('change', this.onContactChange, this); this.listenTo(_converse.roster, 'change', this.onContactChange);
_converse.roster.on("destroy", this.update, this); this.listenTo(_converse.roster, "destroy", this.update);
_converse.roster.on("remove", this.update, this); this.listenTo(_converse.roster, "remove", this.update);
_converse.presences.on('change:show', () => { _converse.presences.on('change:show', () => {
this.update(); this.update();
this.updateFilter(); this.updateFilter();
}); });
this.model.on("reset", this.reset, this); this.listenTo(this.model, "reset", this.reset);
// This event gets triggered once *all* contacts (i.e. not // This event gets triggered once *all* contacts (i.e. not
// just this group's) have been fetched from browser // just this group's) have been fetched from browser
...@@ -801,7 +801,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -801,7 +801,7 @@ converse.plugins.add('converse-rosterview', {
model.id = `_converse.rosterfilter${_converse.bare_jid}`; model.id = `_converse.rosterfilter${_converse.bare_jid}`;
model.browserStorage = new BrowserStorage.local(this.filter.id); model.browserStorage = new BrowserStorage.local(this.filter.id);
this.filter_view = new _converse.RosterFilterView({'model': model}); this.filter_view = new _converse.RosterFilterView({'model': model});
this.filter_view.model.on('change', this.updateFilter, this); this.listenTo(this.filter_view.model, 'change', this.updateFilter);
this.filter_view.model.fetch(); this.filter_view.model.fetch();
}, },
......
...@@ -326,7 +326,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -326,7 +326,7 @@ converse.plugins.add('converse-chatboxes', {
const storage = _converse.config.get('storage'); const storage = _converse.config.get('storage');
this.messages.browserStorage = new BrowserStorage[storage](this.getMessagesCacheKey()); this.messages.browserStorage = new BrowserStorage[storage](this.getMessagesCacheKey());
this.messages.chatbox = this; this.messages.chatbox = this;
this.messages.on('change:upload', (message) => { this.listenTo(this.messages, 'change:upload', message => {
if (message.get('upload') === _converse.SUCCESS) { if (message.get('upload') === _converse.SUCCESS) {
_converse.api.send(this.createMessageStanza(message)); _converse.api.send(this.createMessageStanza(message));
} }
......
...@@ -52,13 +52,13 @@ converse.plugins.add('converse-disco', { ...@@ -52,13 +52,13 @@ converse.plugins.add('converse-disco', {
this.features.browserStorage = new BrowserStorage.session( this.features.browserStorage = new BrowserStorage.session(
`converse.features-${this.get('jid')}` `converse.features-${this.get('jid')}`
); );
this.features.on('add', this.onFeatureAdded, this); this.listenTo(this.features, 'add', this.onFeatureAdded)
this.fields = new _converse.Collection(); this.fields = new _converse.Collection();
this.fields.browserStorage = new BrowserStorage.session( this.fields.browserStorage = new BrowserStorage.session(
`converse.fields-${this.get('jid')}` `converse.fields-${this.get('jid')}`
); );
this.fields.on('add', this.onFieldAdded, this); this.listenTo(this.fields, 'add', this.onFieldAdded)
this.identities = new _converse.Collection(); this.identities = new _converse.Collection();
this.identities.browserStorage = new BrowserStorage.session( this.identities.browserStorage = new BrowserStorage.session(
......
...@@ -2304,5 +2304,3 @@ converse.plugins.add('converse-muc', { ...@@ -2304,5 +2304,3 @@ converse.plugins.add('converse-muc', {
/************************ END API ************************/ /************************ END API ************************/
} }
}); });
...@@ -153,8 +153,8 @@ converse.plugins.add('converse-roster', { ...@@ -153,8 +153,8 @@ converse.plugins.add('converse-roster', {
this.resources = new Resources(); this.resources = new Resources();
const id = `converse.identities-${this.get('jid')}`; const id = `converse.identities-${this.get('jid')}`;
this.resources.browserStorage = new BrowserStorage.session(id); this.resources.browserStorage = new BrowserStorage.session(id);
this.resources.on('update', this.onResourcesChanged, this); this.listenTo(this.resources, 'update', this.onResourcesChanged);
this.resources.on('change', this.onResourcesChanged, this); this.listenTo(this.resources, 'change', this.onResourcesChanged);
}, },
onResourcesChanged () { onResourcesChanged () {
...@@ -253,8 +253,8 @@ converse.plugins.add('converse-roster', { ...@@ -253,8 +253,8 @@ converse.plugins.add('converse-roster', {
* @type { _converse.RosterContact } * @type { _converse.RosterContact }
* @example _converse.api.listen.on('contactPresenceChanged', contact => { ... }); * @example _converse.api.listen.on('contactPresenceChanged', contact => { ... });
*/ */
this.presence.on('change:show', () => _converse.api.trigger('contactPresenceChanged', this)); this.listenTo(this.presence, 'change:show', () => _converse.api.trigger('contactPresenceChanged', this));
this.presence.on('change:show', () => this.trigger('presenceChanged')); this.listenTo(this.presence, 'change:show', () => this.trigger('presenceChanged'));
/** /**
* Synchronous event which provides a hook for further initializing a RosterContact * Synchronous event which provides a hook for further initializing a RosterContact
* @event _converse#rosterContactInitialized * @event _converse#rosterContactInitialized
......
...@@ -61,10 +61,10 @@ var specs = [ ...@@ -61,10 +61,10 @@ var specs = [
"spec/autocomplete", "spec/autocomplete",
"spec/minchats", "spec/minchats",
"spec/notification", "spec/notification",
"spec/emojis",
"spec/login", "spec/login",
"spec/register", "spec/register",
"spec/http-file-upload" "spec/http-file-upload",
"spec/emojis"
]; ];
require(['console-reporter', 'mock', 'sinon'], (ConsoleReporter, mock, sinon) => { require(['console-reporter', 'mock', 'sinon'], (ConsoleReporter, mock, sinon) => {
......
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