diff --git a/spec/muc_messages.js b/spec/muc_messages.js index cd8960fb5..8ca220635 100644 --- a/spec/muc_messages.js +++ b/spec/muc_messages.js @@ -116,6 +116,30 @@ done(); })); + it("can contain a chat state notification and will still be shown", + mock.initConverse( + ['rosterGroupsFetched', 'chatBoxesFetched'], {}, + async function (done, _converse) { + + const muc_jid = 'lounge@montague.lit'; + await test_utils.openAndEnterChatRoom(_converse, muc_jid, 'romeo'); + const view = _converse.api.chatviews.get(muc_jid); + if (!view.el.querySelectorAll('.chat-area').length) { view.renderChatArea(); } + const message = 'romeo: Your attention is required'; + const nick = mock.chatroom_names[0], + msg = $msg({ + from: 'lounge@montague.lit/'+nick, + id: u.getUniqueId(), + to: 'romeo@montague.lit', + type: 'groupchat' + }).c('body').t(message) + .c('active', {'xmlns': "http://jabber.org/protocol/chatstates"}) + .tree(); + await view.model.queueMessage(msg); + await new Promise(resolve => view.once('messageInserted', resolve)); + expect(view.el.querySelector('.chat-msg')).not.toBe(null); + done(); + })); it("is specially marked when you are mentioned in it", mock.initConverse( diff --git a/src/headless/converse-muc.js b/src/headless/converse-muc.js index d6094eb8c..4ff416ad4 100644 --- a/src/headless/converse-muc.js +++ b/src/headless/converse-muc.js @@ -1950,7 +1950,8 @@ converse.plugins.add('converse-muc', { if (attrs['chat_state']) { this.updateCSN(attrs); - } else if (u.shouldCreateGroupchatMessage(attrs)) { + } + if (u.shouldCreateGroupchatMessage(attrs)) { const msg = this.handleCorrection(attrs) || await this.createMessage(attrs); this.incrementUnreadMsgCounter(msg); }