diff --git a/CHANGES.md b/CHANGES.md index 1e09a3645..f650fdeb7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -34,10 +34,11 @@ When leaving a MUC, the message history is deleted. This means that decrypted OMEMO messages are gone and cannot be recovered on that device. See [muc_clear_messages_on_leave](https://conversejs.org/docs/html/configuration.html#muc-clear-messages-on-leave). Removed events: -* `chatBoxInsertedIntoDOM` * `bookmarkViewsInitialized` -* `rosterGroupsFetched` +* `chatBoxInsertedIntoDOM` +* `contactStatusMessageChanged` * `messageSend` (use `sendMessage` instead) +* `rosterGroupsFetched` The `chatBoxClosed`, `chatBoxMaximized` and `chatBoxMinimized` events now have the `model` as payload and not the `view`. diff --git a/src/plugins/chatview/chat.js b/src/plugins/chatview/chat.js index 016b5572f..4642fa3a8 100644 --- a/src/plugins/chatview/chat.js +++ b/src/plugins/chatview/chat.js @@ -25,7 +25,6 @@ export default class ChatView extends BaseChatView { this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged); this.listenTo(this.model, 'change:hidden', () => !this.model.get('hidden') && this.afterShown()); this.listenTo(this.model, 'change:show_help_messages', this.requestUpdate); - this.listenTo(this.model, 'change:status', this.onStatusMessageChanged); await this.model.messages.fetched; !this.model.get('hidden') && this.afterShown() diff --git a/src/plugins/chatview/heading.js b/src/plugins/chatview/heading.js index 2bcf0ea55..f2d32662c 100644 --- a/src/plugins/chatview/heading.js +++ b/src/plugins/chatview/heading.js @@ -21,6 +21,7 @@ export default class ChatHeading extends ElementView { super.connectedCallback(); this.model = _converse.chatboxes.get(this.getAttribute('jid')); this.debouncedRender = debounce(this.render, 100); + this.listenTo(this.model, 'change:status', this.debouncedRender); this.listenTo(this.model, 'vcard:change', this.debouncedRender); if (this.model.contact) { this.listenTo(this.model.contact, 'destroy', this.debouncedRender); diff --git a/src/plugins/muc-views/muc.js b/src/plugins/muc-views/muc.js index a3321f6ec..7225872be 100644 --- a/src/plugins/muc-views/muc.js +++ b/src/plugins/muc-views/muc.js @@ -22,10 +22,10 @@ export default class MUCView extends BaseChatView { this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged); this.listenTo(this.model, 'change:composing_spoiler', this.requestUpdateMessageForm); this.listenTo(this.model, 'show', this.show); - this.listenTo(this.model.session, 'change:connection_status', this.updateAfterTransition); + this.listenTo(this.model.session, 'change:connection_status', this.onConnectionStatusChanged); this.listenTo(this.model.session, 'change:view', this.requestUpdate); - this.updateAfterTransition(); + this.onConnectionStatusChanged(); this.model.maybeShow(); /** * Triggered once a { @link _converse.ChatRoomView } has been opened @@ -71,7 +71,7 @@ export default class MUCView extends BaseChatView { } } - updateAfterTransition () { + onConnectionStatusChanged () { const conn_status = this.model.session.get('connection_status'); if (conn_status === converse.ROOMSTATUS.CONNECTING) { this.model.session.save({ diff --git a/src/plugins/muc-views/tests/muc.js b/src/plugins/muc-views/tests/muc.js index 365b5ba71..ea638054d 100644 --- a/src/plugins/muc-views/tests/muc.js +++ b/src/plugins/muc-views/tests/muc.js @@ -1,4 +1,4 @@ -/*global mock, converse, _ */ +/*global mock, converse */ const $pres = converse.env.$pres; const $iq = converse.env.$iq; @@ -2602,14 +2602,10 @@ describe("Groupchats", function () { // have the same attributes values as the original ones. const attrs = ['id', 'box_id', 'visible']; let new_attrs, old_attrs; - for (var i=0; i m.attributes[attrs[i]]); + old_attrs = _converse.chatboxes.models.map(m => m.attributes[attrs[i]]); + expect(new_attrs.sort()).toEqual(old_attrs.sort()); } done(); })); @@ -2619,13 +2615,13 @@ describe("Groupchats", function () { await mock.openChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); const view = _converse.chatboxviews.get('lounge@montague.lit'); - spyOn(view, 'close').and.callThrough(); + spyOn(view.model, 'close').and.callThrough(); spyOn(_converse.api, "trigger").and.callThrough(); spyOn(view.model, 'leave'); spyOn(_converse.api, 'confirm').and.callFake(() => Promise.resolve(true)); const button = await u.waitUntil(() => view.querySelector('.close-chatbox-button')); button.click(); - await u.waitUntil(() => view.close.calls.count()); + await u.waitUntil(() => view.model.close.calls.count()); expect(view.model.leave).toHaveBeenCalled(); await u.waitUntil(() => _converse.api.trigger.calls.count()); expect(_converse.api.trigger).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object)); @@ -4460,7 +4456,7 @@ describe("Groupchats", function () { modal.el.querySelector('form input[type="submit"]').click(); await u.waitUntil(() => _converse.chatboxes.length); await u.waitUntil(() => sizzle('.chatroom', _converse.el).filter(u.isVisible).length === 1); - expect(_.includes(_converse.chatboxes.models.map(m => m.get('id')), 'lounge@muc.example.org')).toBe(true); + expect(_converse.chatboxes.models.map(m => m.get('id')).includes('lounge@muc.example.org')).toBe(true); // However, you can still open MUCs with different domains roomspanel.querySelector('.show-add-muc-modal').click(); @@ -4472,7 +4468,7 @@ describe("Groupchats", function () { modal.el.querySelector('form input[type="submit"]').click(); await u.waitUntil(() => _converse.chatboxes.models.filter(c => c.get('type') === 'chatroom').length === 2); await u.waitUntil(() => sizzle('.chatroom', _converse.el).filter(u.isVisible).length === 2); - expect(_.includes(_converse.chatboxes.models.map(m => m.get('id')), 'lounge@conference.example.org')).toBe(true); + expect(_converse.chatboxes.models.map(m => m.get('id')).includes('lounge@conference.example.org')).toBe(true); done(); })); @@ -4498,7 +4494,7 @@ describe("Groupchats", function () { modal.el.querySelector('form input[type="submit"]').click(); await u.waitUntil(() => _converse.chatboxes.length); await u.waitUntil(() => sizzle('.chatroom', _converse.el).filter(u.isVisible).length === 1); - expect(_.includes(_converse.chatboxes.models.map(m => m.get('id')), 'lounge@muc.example.org')).toBe(true); + expect(_converse.chatboxes.models.map(m => m.get('id')).includes('lounge@muc.example.org')).toBe(true); // However, you can still open MUCs with different domains roomspanel.querySelector('.show-add-muc-modal').click(); @@ -4510,7 +4506,7 @@ describe("Groupchats", function () { modal.el.querySelector('form input[type="submit"]').click(); await u.waitUntil(() => _converse.chatboxes.models.filter(c => c.get('type') === 'chatroom').length === 2); await u.waitUntil(() => sizzle('.chatroom', _converse.el).filter(u.isVisible).length === 2); - expect(_.includes(_converse.chatboxes.models.map(m => m.get('id')), 'lounge\\40conference@muc.example.org')).toBe(true); + expect(_converse.chatboxes.models.map(m => m.get('id')).includes('lounge\\40conference@muc.example.org')).toBe(true); done(); })); }); diff --git a/src/shared/chat/baseview.js b/src/shared/chat/baseview.js index c9e2c039b..41b6d614f 100644 --- a/src/shared/chat/baseview.js +++ b/src/shared/chat/baseview.js @@ -72,22 +72,6 @@ export default class BaseChatView extends CustomElement { api.trigger('chatBoxFocused', this, ev); } - onStatusMessageChanged (item) { - this.renderHeading(); - /** - * When a contact's custom status message has changed. - * @event _converse#contactStatusMessageChanged - * @type {object} - * @property { object } contact - The chat buddy - * @property { string } message - The message text - * @example _converse.api.listen.on('contactStatusMessageChanged', obj => { ... }); - */ - api.trigger('contactStatusMessageChanged', { - 'contact': item.attributes, - 'message': item.get('status') - }); - } - getBottomPanel () { if (this.model.get('type') === _converse.CHATROOMS_TYPE) { return this.querySelector('converse-muc-bottom-panel');