Commit 30e784b8 authored by JC Brand's avatar JC Brand

Fix: `use_system_emojis` was `false` but unicode emojis shown in picker

parent 33f62bb9
...@@ -5,7 +5,7 @@ const u = converse.env.utils; ...@@ -5,7 +5,7 @@ const u = converse.env.utils;
const original_timeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; const original_timeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
describe("Emojis", function () { fdescribe("Emojis", function () {
describe("The emoji picker", function () { describe("The emoji picker", function () {
beforeEach(() => (jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000)); beforeEach(() => (jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000));
...@@ -347,18 +347,19 @@ describe("Emojis", function () { ...@@ -347,18 +347,19 @@ describe("Emojis", function () {
async function (done, _converse) { async function (done, _converse) {
await mock.waitForRoster(_converse, 'current'); await mock.waitForRoster(_converse, 'current');
const sender_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@montague.lit'; const contact_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@montague.lit';
_converse.handleMessageStanza($msg({ _converse.handleMessageStanza($msg({
'from': sender_jid, 'from': contact_jid,
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': _converse.connection.getUniqueId() 'id': _converse.connection.getUniqueId()
}).c('body').t('😇').up() }).c('body').t('😇').up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
await new Promise(resolve => _converse.on('chatBoxViewInitialized', resolve)); await new Promise(resolve => _converse.on('chatBoxViewInitialized', resolve));
const view = _converse.api.chatviews.get(sender_jid); const view = _converse.api.chatviews.get(contact_jid);
await new Promise(resolve => view.model.messages.once('rendered', resolve)); await new Promise(resolve => view.model.messages.once('rendered', resolve));
await u.waitUntil(() => u.hasClass('chat-msg__text--larger', view.content.querySelector('.chat-msg__text'))); await u.waitUntil(() => view.content.querySelector('.chat-msg__text').innerHTML.replace(/<!---->/g, '') ===
'<img class="emoji" draggable="false" title=":innocent:" alt="😇" src="https://twemoji.maxcdn.com/v/12.1.6//72x72/1f607.png">');
const last_msg_sel = 'converse-chat-message:last-child .chat-msg__text'; const last_msg_sel = 'converse-chat-message:last-child .chat-msg__text';
let message = view.content.querySelector(last_msg_sel); let message = view.content.querySelector(last_msg_sel);
...@@ -381,6 +382,10 @@ describe("Emojis", function () { ...@@ -381,6 +382,10 @@ describe("Emojis", function () {
expect(imgs.length).toBe(2); expect(imgs.length).toBe(2);
expect(imgs[0].src).toBe(_converse.api.settings.get('emoji_image_path')+'/72x72/1f4a9.png'); expect(imgs[0].src).toBe(_converse.api.settings.get('emoji_image_path')+'/72x72/1f4a9.png');
expect(imgs[1].src).toBe(_converse.api.settings.get('emoji_image_path')+'/72x72/1f607.png'); expect(imgs[1].src).toBe(_converse.api.settings.get('emoji_image_path')+'/72x72/1f607.png');
const sent_stanzas = _converse.connection.sent_stanzas;
const sent_stanza = sent_stanzas.filter(s => s.nodeName === 'message').pop();
expect(sent_stanza.querySelector('body').innerHTML).toBe('💩 😇');
done() done()
})); }));
......
...@@ -119,19 +119,21 @@ export function getEmojiMarkup (data, options={unicode_only: false, add_title_wr ...@@ -119,19 +119,21 @@ export function getEmojiMarkup (data, options={unicode_only: false, add_title_wr
const emoji = data.emoji; const emoji = data.emoji;
const shortname = data.shortname; const shortname = data.shortname;
if (emoji) { if (emoji) {
if (options.add_title_wrapper) { if (options.unicode_only) {
if (api.settings.get('use_system_emojis')) { return emoji;
} else if (api.settings.get('use_system_emojis')) {
if (options.add_title_wrapper) {
return shortname ? html`<span title="${shortname}">${emoji}</span>` : emoji; return shortname ? html`<span title="${shortname}">${emoji}</span>` : emoji;
} else { } else {
const path = api.settings.get('emoji_image_path'); return emoji;
return html`<img class="emoji"
draggable="false"
title="${shortname}"
alt="${emoji}"
src="${path}/72x72/${data.cp}.png"/>`;
} }
} else { } else {
return emoji; const path = api.settings.get('emoji_image_path');
return html`<img class="emoji"
draggable="false"
title="${shortname}"
alt="${emoji}"
src="${path}/72x72/${data.cp}.png"/>`;
} }
} else if (options.unicode_only) { } else if (options.unicode_only) {
return shortname; return shortname;
......
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