Commit 99f539b3 authored by JC Brand's avatar JC Brand

MUC: Don't show duplicate subsequent `info` messages

parent 3d4bad4b
......@@ -39,6 +39,32 @@
expect(u.hasClass('chat-msg--followup', messages[1])).toBe(false);
done();
}));
it("is not shown if its a duplicate",
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);
await u.waitUntil(() => view.el.querySelectorAll('.chat-info').length);
const presence = u.toStanza(`
<presence xmlns="jabber:client" to="${_converse.jid}" from="${muc_jid}/romeo">
<x xmlns="http://jabber.org/protocol/muc#user">
<status code="201"/>
<item role="moderator" affiliation="owner" jid="${_converse.jid}"/>
<status code="110"/>
</x>
</presence>
`);
_converse.connection._dataRecv(test_utils.createRequest(presence));
_converse.connection._dataRecv(test_utils.createRequest(presence));
await u.waitUntil(() => view.el.querySelectorAll('.chat-info').length > 1);
expect(view.el.querySelectorAll('.chat-info').length).toBe(2);
done();
}));
});
......
......@@ -1791,6 +1791,14 @@ converse.plugins.add('converse-muc', {
message = __(_converse.muc.new_nickname_messages[code], nick);
}
if (message) {
if (code === "201" && this.messages.findWhere({'type': 'info', message})) {
return;
} else if (code in _converse.muc.info_messages &&
this.messages.length &&
this.messages.pop().get('message') === message) {
// XXX: very naive duplication checking
return;
}
this.messages.create({'type': 'info', message});
}
});
......
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