Commit e305cc35 authored by JC Brand's avatar JC Brand

Remove `--larger` class on a edited message that's no longer just emojis

parent 54c90e14
...@@ -159,9 +159,9 @@ ...@@ -159,9 +159,9 @@
}); });
describe("A Chat Message", function () { describe("A Chat Message", function () {
it("will display larger if it's a single emoji", it("will display larger if it's only emojis",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {'use_system_emojis': false}, null, ['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {'use_system_emojis': true},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
...@@ -176,7 +176,6 @@ ...@@ -176,7 +176,6 @@
await new Promise(resolve => _converse.on('chatBoxInitialized', resolve)); await new Promise(resolve => _converse.on('chatBoxInitialized', resolve));
const view = _converse.api.chatviews.get(sender_jid); const view = _converse.api.chatviews.get(sender_jid);
await new Promise((resolve, reject) => view.once('messageInserted', resolve)); await new Promise((resolve, reject) => view.once('messageInserted', resolve));
const chat_content = view.el.querySelector('.chat-content'); const chat_content = view.el.querySelector('.chat-content');
let message = chat_content.querySelector('.chat-msg__text'); let message = chat_content.querySelector('.chat-msg__text');
expect(u.hasClass('chat-msg__text--larger', message)).toBe(true); expect(u.hasClass('chat-msg__text--larger', message)).toBe(true);
...@@ -191,7 +190,38 @@ ...@@ -191,7 +190,38 @@
await new Promise((resolve, reject) => view.once('messageInserted', resolve)); await new Promise((resolve, reject) => view.once('messageInserted', resolve));
message = chat_content.querySelector('.message:last-child .chat-msg__text'); message = chat_content.querySelector('.message:last-child .chat-msg__text');
expect(u.hasClass('chat-msg__text--larger', message)).toBe(false); expect(u.hasClass('chat-msg__text--larger', message)).toBe(false);
done();
// Test that a modified message that no longer contains only
// emojis now renders normally again.
const textarea = view.el.querySelector('textarea.chat-textarea');
textarea.value = ':poop: :innocent:';
view.onKeyDown({
target: textarea,
preventDefault: function preventDefault () {},
keyCode: 13 // Enter
});
await new Promise((resolve, reject) => view.once('messageInserted', resolve));
expect(view.el.querySelectorAll('.chat-msg').length).toBe(3);
expect(chat_content.querySelector('.message:last-child .chat-msg__text').textContent).toBe('💩 😇');
expect(textarea.value).toBe('');
view.onKeyDown({
target: textarea,
keyCode: 38 // Up arrow
});
expect(textarea.value).toBe('💩 😇');
expect(view.model.messages.at(2).get('correcting')).toBe(true);
await u.waitUntil(() => u.hasClass('correcting', view.el.querySelector('.chat-msg:last-child')), 500);
textarea.value = textarea.value += 'This is no longer an emoji-only message';
view.onKeyDown({
target: textarea,
preventDefault: function preventDefault () {},
keyCode: 13 // Enter
});
await new Promise((resolve, reject) => view.model.messages.once('rendered', resolve));
expect(view.model.messages.models.length).toBe(3);
message = chat_content.querySelector('.message:last-child .chat-msg__text');
expect(u.hasClass('chat-msg__text--larger', message)).toBe(false);
done()
})); }));
}); });
}); });
......
...@@ -558,7 +558,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -558,7 +558,7 @@ converse.plugins.add('converse-chatboxes', {
} }
const older_versions = message.get('older_versions') || {}; const older_versions = message.get('older_versions') || {};
if ((attrs.time < message.get('time')) && message.get('edited')) { if ((attrs.time < message.get('time')) && message.get('edited')) {
// This is an older message which has been corrected already // This is an older message which has been corrected afterwards
older_versions[attrs.time] = attrs['message']; older_versions[attrs.time] = attrs['message'];
message.save({'older_versions': older_versions}); message.save({'older_versions': older_versions});
} else { } else {
...@@ -787,6 +787,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -787,6 +787,7 @@ converse.plugins.add('converse-chatboxes', {
'message': attrs.message, 'message': attrs.message,
'older_versions': older_versions, 'older_versions': older_versions,
'references': attrs.references, 'references': attrs.references,
'is_single_emoji': attrs.message ? u.isSingleEmoji(attrs.message) : false,
'origin_id': _converse.connection.getUniqueId(), 'origin_id': _converse.connection.getUniqueId(),
'received': undefined 'received': undefined
}); });
......
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