Commit 3d4bad4b authored by JC Brand's avatar JC Brand

Don't mark info messages as followups

parent 657dd1e6
...@@ -52,9 +52,6 @@ ...@@ -52,9 +52,6 @@
font-size: 90%; font-size: 90%;
padding: 0.17rem 1rem; padding: 0.17rem 1rem;
&.chat-msg--followup {
margin-left: 2.75rem;
}
&.badge { &.badge {
color: var(--chat-head-text-color); color: var(--chat-head-text-color);
} }
...@@ -348,11 +345,6 @@ ...@@ -348,11 +345,6 @@
} }
} }
} }
&.chat-info {
&.chat-msg--followup {
margin-left: 0;
}
}
} }
} }
......
...@@ -11,6 +11,37 @@ ...@@ -11,6 +11,37 @@
describe("A Groupchat Message", function () { describe("A Groupchat Message", function () {
describe("an info message", function () {
it("is not rendered as a followup message",
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);
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));
await u.waitUntil(() => view.el.querySelectorAll('.chat-info').length === 2);
const messages = view.el.querySelectorAll('.chat-info');
expect(u.hasClass('chat-msg--followup', messages[0])).toBe(false);
expect(u.hasClass('chat-msg--followup', messages[1])).toBe(false);
done();
}));
});
it("is rejected if it's an unencapsulated forwarded message", it("is rejected if it's an unencapsulated forwarded message",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
......
...@@ -658,12 +658,13 @@ converse.plugins.add('converse-chatview', { ...@@ -658,12 +658,13 @@ converse.plugins.add('converse-chatview', {
* @param { HTMLElement } el - The message element * @param { HTMLElement } el - The message element
*/ */
markFollowups (el) { markFollowups (el) {
const from = el.getAttribute('data-from'), const from = el.getAttribute('data-from');
previous_el = el.previousElementSibling, const previous_el = el.previousElementSibling;
date = dayjs(el.getAttribute('data-isodate')), const date = dayjs(el.getAttribute('data-isodate'));
next_el = el.nextElementSibling; const next_el = el.nextElementSibling;
if (!u.hasClass('chat-msg--action', el) && !u.hasClass('chat-msg--action', previous_el) && if (!u.hasClass('chat-msg--action', el) && !u.hasClass('chat-msg--action', previous_el) &&
!u.hasClass('chat-info', el) && !u.hasClass('chat-info', previous_el) &&
previous_el.getAttribute('data-from') === from && previous_el.getAttribute('data-from') === from &&
date.isBefore(dayjs(previous_el.getAttribute('data-isodate')).add(10, 'minutes')) && date.isBefore(dayjs(previous_el.getAttribute('data-isodate')).add(10, 'minutes')) &&
el.getAttribute('data-encrypted') === previous_el.getAttribute('data-encrypted')) { el.getAttribute('data-encrypted') === previous_el.getAttribute('data-encrypted')) {
...@@ -671,7 +672,7 @@ converse.plugins.add('converse-chatview', { ...@@ -671,7 +672,7 @@ converse.plugins.add('converse-chatview', {
} }
if (!next_el) { return; } if (!next_el) { return; }
if (!u.hasClass('chat-msg--action', el) && if (!u.hasClass('chat-msg--action', el) && u.hasClass('chat-info', el) &&
next_el.getAttribute('data-from') === from && next_el.getAttribute('data-from') === from &&
dayjs(next_el.getAttribute('data-isodate')).isBefore(date.add(10, 'minutes')) && dayjs(next_el.getAttribute('data-isodate')).isBefore(date.add(10, 'minutes')) &&
el.getAttribute('data-encrypted') === next_el.getAttribute('data-encrypted')) { el.getAttribute('data-encrypted') === next_el.getAttribute('data-encrypted')) {
......
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