Commit 7eb6b13f authored by JC Brand's avatar JC Brand

Don't mark /me messages are followup messages.

parent 911ede28
......@@ -8433,8 +8433,12 @@ body.reset {
#conversejs .message.chat-msg .chat-msg-heading .chat-msg-time {
padding-left: 0.25em;
color: #9d9d9d; }
#conversejs .message.chat-msg.chat-action .chat-msg-heading {
margin-top: 0; }
#conversejs .message.chat-msg.chat-action {
display: block; }
#conversejs .message.chat-msg.chat-action .chat-msg-heading {
float: left;
margin-top: 0;
padding-bottom: 0; }
#conversejs .message.chat-msg.chat-msg-followup .chat-msg-heading,
#conversejs .message.chat-msg.chat-msg-followup .avatar {
display: none; }
......
......@@ -8621,8 +8621,12 @@ body {
#conversejs .message.chat-msg .chat-msg-heading .chat-msg-time {
padding-left: 0.25em;
color: #9d9d9d; }
#conversejs .message.chat-msg.chat-action .chat-msg-heading {
margin-top: 0; }
#conversejs .message.chat-msg.chat-action {
display: block; }
#conversejs .message.chat-msg.chat-action .chat-msg-heading {
float: left;
margin-top: 0;
padding-bottom: 0; }
#conversejs .message.chat-msg.chat-msg-followup .chat-msg-heading,
#conversejs .message.chat-msg.chat-msg-followup .avatar {
display: none; }
......
......@@ -144,8 +144,12 @@
}
}
&.chat-action {
display: block;
.chat-msg-heading {
float: left;
margin-top: 0;
padding-bottom: 0;
}
}
&.chat-msg-followup {
......
......@@ -58,11 +58,8 @@
var view;
test_utils.createContacts(_converse, 'current');
test_utils.waitUntilDiscoConfirmed(_converse, 'localhost', [], ['vcard-temp'])
.then(() => test_utils.waitUntil(() => _converse.xmppstatus.get('fullname')), 300)
.then(function () {
return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname');
}, 300);
}).then(function () {
test_utils.openControlBox();
expect(_converse.chatboxes.length).toEqual(1);
var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
......@@ -81,14 +78,35 @@
test_utils.waitUntil(function () {
return u.isVisible(view.el);
}).then(function () {
expect(view.el.querySelectorAll('.chat-action').length).toBe(1);
expect(_.includes(view.el.querySelector('.chat-msg-author').textContent, '**Max Frankfurter')).toBeTruthy();
expect($(view.el).find('.chat-msg-text').text()).toBe(' is tired');
message = '/me is as well';
test_utils.sendMessage(view, message);
expect(view.el.querySelectorAll('.chat-action').length).toBe(2);
expect(_.includes($(view.el).find('.chat-msg-author:last').text(), '**Max Mustermann')).toBeTruthy();
expect($(view.el).find('.chat-msg-text:last').text()).toBe(' is as well');
expect($(view.el).find('.chat-msg:last').hasClass('chat-msg-followup')).toBe(false);
// Check that /me messages after a normal message don't
// get the 'chat-msg-followup' class.
message = 'This a normal message';
test_utils.sendMessage(view, message);
let message_el = view.el.querySelector('.message:last-child');
expect(u.hasClass('chat-msg-followup', message_el)).toBeFalsy();
message = '/me wrote a 3rd person message';
test_utils.sendMessage(view, message);
message_el = view.el.querySelector('.message:last-child');
expect(view.el.querySelectorAll('.chat-action').length).toBe(3);
expect($(view.el).find('.chat-msg-text:last').text()).toBe(' wrote a 3rd person message');
expect($(view.el).find('.chat-msg-author:last').is(':visible')).toBeTruthy();
expect(u.hasClass('chat-msg-followup', message_el)).toBeFalsy();
message = 'This a normal message';
done();
});
});
......
......@@ -683,25 +683,22 @@
*/
const from = el.getAttribute('data-from'),
previous_el = el.previousElementSibling,
date = moment(el.getAttribute('data-isodate'));
if (previous_el.getAttribute('data-from') === from &&
date.isBefore(moment(previous_el.getAttribute('data-isodate')).add(10, 'minutes'))) {
date = moment(el.getAttribute('data-isodate')),
next_el = el.nextElementSibling;
if (!u.hasClass('chat-action', el) && !u.hasClass('chat-action', previous_el) &&
previous_el.getAttribute('data-from') === from &&
date.isBefore(moment(previous_el.getAttribute('data-isodate')).add(10, 'minutes'))) {
u.addClass('chat-msg-followup', el);
}
const next_el = el.nextElementSibling;
if (!next_el) {
return;
}
if (next_el.getAttribute('data-from') !== from) {
u.removeClass('chat-msg-followup', next_el);
if (!next_el) { return; }
if (!u.hasClass('chat-action', 'el') &&
next_el.getAttribute('data-from') === from &&
moment(next_el.getAttribute('data-isodate')).isBefore(date.add(10, 'minutes'))) {
u.addClass('chat-msg-followup', next_el);
} else {
if (moment(next_el.getAttribute('data-isodate')).isBefore(date.add(10, 'minutes'))) {
u.addClass('chat-msg-followup', next_el);
} else {
u.removeClass('chat-msg-followup', next_el);
}
u.removeClass('chat-msg-followup', next_el);
}
},
......
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