emoji: Lazy load the emoji JSON

Only load it once the first chat has been opened.
This commit is contained in:
JC Brand 2020-01-21 12:45:34 +01:00
parent d5472a8d23
commit b0a9782d31
15 changed files with 95 additions and 199 deletions

View File

@ -16,9 +16,7 @@
describe("A chat room", function () { describe("A chat room", function () {
it("can be bookmarked", mock.initConverse( it("can be bookmarked", mock.initConverse(['rosterGroupsFetched'], {}, async function (done, _converse) {
['rosterGroupsFetched', 'emojisInitialized'], {},
async function (done, _converse) {
await test_utils.waitUntilDiscoConfirmed( await test_utils.waitUntilDiscoConfirmed(
_converse, _converse.bare_jid, _converse, _converse.bare_jid,

View File

@ -162,7 +162,7 @@
})); }));
it("can be trimmed to conserve space", it("can be trimmed to conserve space",
mock.initConverse(['rosterGroupsFetched', 'emojisInitialized'], {}, mock.initConverse(['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
spyOn(_converse.chatboxviews, 'trimChats'); spyOn(_converse.chatboxviews, 'trimChats');
@ -523,7 +523,7 @@
it("does not open a new chatbox", it("does not open a new chatbox",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
@ -884,7 +884,7 @@
it("is sent if the user has stopped typing since 2 minutes", it("is sent if the user has stopped typing since 2 minutes",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
const sent_stanzas = _converse.connection.sent_stanzas; const sent_stanzas = _converse.connection.sent_stanzas;
@ -1190,7 +1190,7 @@
it("is incremented from zero when chatbox was closed after viewing previously received messages and the window is not focused now", it("is incremented from zero when chatbox was closed after viewing previously received messages and the window is not focused now",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
@ -1271,7 +1271,7 @@
})); }));
it("is incremeted when message is received, chatbox is scrolled down and the window is not focused", it("is incremeted when message is received, chatbox is scrolled down and the window is not focused",
mock.initConverse(['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, mock.initConverse(['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
@ -1291,7 +1291,7 @@
it("is incremeted when message is received, chatbox is scrolled up and the window is not focused", it("is incremeted when message is received, chatbox is scrolled up and the window is not focused",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);
@ -1309,7 +1309,7 @@
it("is cleared when ChatBoxView was scrolled down and the window become focused", it("is cleared when ChatBoxView was scrolled down and the window become focused",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);
@ -1328,7 +1328,7 @@
it("is not cleared when ChatBoxView was scrolled up and the windows become focused", it("is not cleared when ChatBoxView was scrolled up and the windows become focused",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);
@ -1433,7 +1433,7 @@
it("is cleared when unread messages are viewed which were received in scrolled-up chatbox", it("is cleared when unread messages are viewed which were received in scrolled-up chatbox",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openControlBox(_converse); await test_utils.openControlBox(_converse);
@ -1458,7 +1458,7 @@
it("is not cleared after user clicks on roster view when chatbox is already opened and scrolled up", it("is not cleared after user clicks on roster view when chatbox is already opened and scrolled up",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);
@ -1485,7 +1485,7 @@
it("is displayed when scrolled up chatbox is minimized after receiving unread messages", it("is displayed when scrolled up chatbox is minimized after receiving unread messages",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);
@ -1513,7 +1513,7 @@
it("is incremented when message is received and windows is not focused", it("is incremented when message is received and windows is not focused",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);

View File

@ -38,7 +38,7 @@
it("can be used to add contact and it checks for case-sensivity", it("can be used to add contact and it checks for case-sensivity",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
spyOn(_converse.api, "trigger").and.callThrough(); spyOn(_converse.api, "trigger").and.callThrough();

View File

@ -214,9 +214,7 @@
describe("The \"contacts\" API", function () { describe("The \"contacts\" API", function () {
it("has a method 'get' which returns wrapped contacts", it("has a method 'get' which returns wrapped contacts",
mock.initConverse( mock.initConverse([], {}, async function (done, _converse) {
['emojisInitialized'], {},
async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
let contact = await _converse.api.contacts.get('non-existing@jabber.org'); let contact = await _converse.api.contacts.get('non-existing@jabber.org');

View File

@ -105,7 +105,7 @@
it("allows you to search for particular emojis", it("allows you to search for particular emojis",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
const muc_jid = 'lounge@montague.lit'; const muc_jid = 'lounge@montague.lit';
@ -158,7 +158,7 @@
describe("A Chat Message", function () { describe("A Chat Message", function () {
it("will display larger if it's only emojis", it("will display larger if it's only emojis",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {'use_system_emojis': true}, ['rosterGroupsFetched', 'chatBoxesFetched'], {'use_system_emojis': true},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');

View File

@ -171,9 +171,7 @@
describe("A file upload toolbar button", function () { describe("A file upload toolbar button", function () {
it("does not appear in private chats", it("does not appear in private chats",
mock.initConverse( mock.initConverse([], {}, async function (done, _converse) {
['emojisInitialized'], {},
async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 3); await test_utils.waitForRoster(_converse, 'current', 3);
test_utils.openControlBox(_converse); test_utils.openControlBox(_converse);
@ -461,9 +459,7 @@
})); }));
it("shows an error message if the file is too large", it("shows an error message if the file is too large",
mock.initConverse( mock.initConverse([], {}, async function (done, _converse) {
['emojisInitialized'], {},
async function (done, _converse) {
const IQ_stanzas = _converse.connection.IQ_stanzas; const IQ_stanzas = _converse.connection.IQ_stanzas;
const IQ_ids = _converse.connection.IQ_ids; const IQ_ids = _converse.connection.IQ_ids;

View File

@ -985,7 +985,7 @@
it("will render images from their URLs", it("will render images from their URLs",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
@ -1033,7 +1033,7 @@
it("will render the message time as configured", it("will render the message time as configured",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
@ -1059,7 +1059,7 @@
it("will be correctly identified and rendered as a followup message", it("will be correctly identified and rendered as a followup message",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
@ -1381,7 +1381,7 @@
it("will open a chatbox and be displayed inside it", it("will open a chatbox and be displayed inside it",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
const include_nick = false; const include_nick = false;
@ -1427,7 +1427,7 @@
it("will be trimmed of leading and trailing whitespace", it("will be trimmed of leading and trailing whitespace",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1, false); await test_utils.waitForRoster(_converse, 'current', 1, false);
@ -1519,7 +1519,7 @@
it("the VCard for that user is fetched and the chatbox updated with the results", it("the VCard for that user is fetched and the chatbox updated with the results",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {'allow_non_roster_messaging': true}, ['rosterGroupsFetched'], {'allow_non_roster_messaging': true},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 0); await test_utils.waitForRoster(_converse, 'current', 0);
@ -1635,7 +1635,7 @@
it("will have the error message displayed after itself", it("will have the error message displayed after itself",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);
@ -1847,7 +1847,7 @@
it("is ignored if it's intended for a different resource and filter_by_resource is set to true", it("is ignored if it's intended for a different resource and filter_by_resource is set to true",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
@ -2098,7 +2098,7 @@
it("is not sent when a markable message is received from someone not on the roster", it("is not sent when a markable message is received from someone not on the roster",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {'allow_non_roster_messaging': true}, ['rosterGroupsFetched'], {'allow_non_roster_messaging': true},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 0); await test_utils.waitForRoster(_converse, 'current', 0);

View File

@ -269,7 +269,7 @@
it("will be created when muc_instant_rooms is set to true", it("will be created when muc_instant_rooms is set to true",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
let IQ_stanzas = _converse.connection.IQ_stanzas; let IQ_stanzas = _converse.connection.IQ_stanzas;
@ -507,7 +507,7 @@
it("is opened when an xmpp: URI is clicked inside another groupchat", it("is opened when an xmpp: URI is clicked inside another groupchat",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current');
@ -535,7 +535,7 @@
it("shows a notification if it's not anonymous", it("shows a notification if it's not anonymous",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
const muc_jid = 'coven@chat.shakespeare.lit'; const muc_jid = 'coven@chat.shakespeare.lit';
@ -579,7 +579,7 @@
it("shows join/leave messages when users enter or exit a groupchat", it("shows join/leave messages when users enter or exit a groupchat",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
const muc_jid = 'coven@chat.shakespeare.lit'; const muc_jid = 'coven@chat.shakespeare.lit';
@ -1648,7 +1648,7 @@
it("shows users currently present in the groupchat", it("shows users currently present in the groupchat",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
@ -2188,7 +2188,7 @@
it("escapes the subject before rendering it, to avoid JS-injection attacks", it("escapes the subject before rendering it, to avoid JS-injection attacks",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'jdev@conference.jabber.org', 'jc'); await test_utils.openAndEnterChatRoom(_converse, 'jdev@conference.jabber.org', 'jc');
@ -2711,7 +2711,7 @@
it("informs users if they have been kicked out of the groupchat", it("informs users if they have been kicked out of the groupchat",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
/* <presence /* <presence
@ -3514,7 +3514,7 @@
it("takes a /kick command to kick a user", it("takes a /kick command to kick a user",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
let sent_IQ, IQ_id; let sent_IQ, IQ_id;
@ -3956,7 +3956,7 @@
it("will show an error message if the groupchat requires a password", it("will show an error message if the groupchat requires a password",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
const muc_jid = 'protected'; const muc_jid = 'protected';
@ -4747,7 +4747,7 @@
it("can be opened from a link in the \"Groupchats\" section of the controlbox", it("can be opened from a link in the \"Groupchats\" section of the controlbox",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openControlBox(_converse); await test_utils.openControlBox(_converse);
@ -4891,7 +4891,7 @@
it("shows the number of unread mentions received", it("shows the number of unread mentions received",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], {'allow_bookmarks': false}, ['rosterGroupsFetched'], {'allow_bookmarks': false},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openControlBox(_converse); await test_utils.openControlBox(_converse);

View File

@ -93,7 +93,7 @@
it("enables encrypted messages to be sent and received", it("enables encrypted messages to be sent and received",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
let sent_stanza; let sent_stanza;

View File

@ -8,7 +8,7 @@
describe("A list of open groupchats", function () { describe("A list of open groupchats", function () {
it("is shown in controlbox", mock.initConverse( it("is shown in controlbox", mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], ['rosterGroupsFetched', 'chatBoxesFetched'],
{ allow_bookmarks: false // Makes testing easier, otherwise we { allow_bookmarks: false // Makes testing easier, otherwise we
// have to mock stanza traffic. // have to mock stanza traffic.
}, async function (done, _converse) { }, async function (done, _converse) {
@ -50,7 +50,7 @@
it("uses bookmarks to determine groupchat names", it("uses bookmarks to determine groupchat names",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], ['rosterGroupsFetched', 'chatBoxesFetched'],
{'view_mode': 'fullscreen'}, {'view_mode': 'fullscreen'},
async function (done, _converse) { async function (done, _converse) {
@ -110,7 +110,7 @@
describe("A groupchat shown in the groupchats list", function () { describe("A groupchat shown in the groupchats list", function () {
it("is highlighted if it's currently open", mock.initConverse( it("is highlighted if it's currently open", mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], ['rosterGroupsFetched', 'chatBoxesFetched'],
{ view_mode: 'fullscreen', { view_mode: 'fullscreen',
allow_bookmarks: false // Makes testing easier, otherwise we have to mock stanza traffic. allow_bookmarks: false // Makes testing easier, otherwise we have to mock stanza traffic.
}, async function (done, _converse) { }, async function (done, _converse) {
@ -139,7 +139,7 @@
})); }));
it("has an info icon which opens a details modal when clicked", mock.initConverse( it("has an info icon which opens a details modal when clicked", mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], ['rosterGroupsFetched', 'chatBoxesFetched'],
{ whitelisted_plugins: ['converse-roomslist'], { whitelisted_plugins: ['converse-roomslist'],
allow_bookmarks: false // Makes testing easier, otherwise we allow_bookmarks: false // Makes testing easier, otherwise we
// have to mock stanza traffic. // have to mock stanza traffic.
@ -244,7 +244,7 @@
})); }));
it("can be closed", mock.initConverse( it("can be closed", mock.initConverse(
['rosterGroupsFetched', 'emojisInitialized'], ['rosterGroupsFetched'],
{ whitelisted_plugins: ['converse-roomslist'], { whitelisted_plugins: ['converse-roomslist'],
allow_bookmarks: false // Makes testing easier, otherwise we have to mock stanza traffic. allow_bookmarks: false // Makes testing easier, otherwise we have to mock stanza traffic.
}, },

View File

@ -11,9 +11,9 @@
return describe("The User Details Modal", function () { return describe("The User Details Modal", function () {
it("can be used to remove a contact", it("can be used to remove a contact",
mock.initConverse( mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched', 'emojisInitialized'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);
_converse.api.trigger('rosterContactsFetched'); _converse.api.trigger('rosterContactsFetched');
@ -44,9 +44,7 @@
})); }));
it("shows an alert when an error happened while removing the contact", it("shows an alert when an error happened while removing the contact",
mock.initConverse( mock.initConverse(['rosterGroupsFetched'], {}, async function (done, _converse) {
['rosterGroupsFetched', 'emojisInitialized'], {},
async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current', 1); await test_utils.waitForRoster(_converse, 'current', 1);
_converse.api.trigger('rosterContactsFetched'); _converse.api.trigger('rosterContactsFetched');

View File

@ -86,9 +86,7 @@ converse.plugins.add('converse-chatboxes', {
}, },
onConnected (reconnecting) { onConnected (reconnecting) {
if (reconnecting) { if (reconnecting) { return; }
return;
}
this.browserStorage = _converse.createStore(`converse.chatboxes-${_converse.bare_jid}`); this.browserStorage = _converse.createStore(`converse.chatboxes-${_converse.bare_jid}`);
this.fetch({ this.fetch({
'add': true, 'add': true,

View File

@ -14,121 +14,19 @@ const { Backbone } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
const ASCII_LIST = { const ASCII_LIST = {
'*\\0/*':'1f646', '*\\0/*':'1f646', '*\\O/*':'1f646', '-___-':'1f611', ':\'-)':'1f602', '\':-)':'1f605', '\':-D':'1f605', '>:-)':'1f606', '\':-(':'1f613',
'*\\O/*':'1f646', '>:-(':'1f620', ':\'-(':'1f622', 'O:-)':'1f607', '0:-3':'1f607', '0:-)':'1f607', '0;^)':'1f607', 'O;-)':'1f607', '0;-)':'1f607', 'O:-3':'1f607',
'-___-':'1f611', '-__-':'1f611', ':-Þ':'1f61b', '</3':'1f494', ':\')':'1f602', ':-D':'1f603', '\':)':'1f605', '\'=)':'1f605', '\':D':'1f605', '\'=D':'1f605',
':\'-)':'1f602', '>:)':'1f606', '>;)':'1f606', '>=)':'1f606', ';-)':'1f609', '*-)':'1f609', ';-]':'1f609', ';^)':'1f609', '\':(':'1f613', '\'=(':'1f613',
'\':-)':'1f605', ':-*':'1f618', ':^*':'1f618', '>:P':'1f61c', 'X-P':'1f61c', '>:[':'1f61e', ':-(':'1f61e', ':-[':'1f61e', '>:(':'1f620', ':\'(':'1f622',
'\':-D':'1f605', ';-(':'1f622', '>.<':'1f623', '#-)':'1f635', '%-)':'1f635', 'X-)':'1f635', '\\0/':'1f646', '\\O/':'1f646', '0:3':'1f607', '0:)':'1f607',
'>:-)':'1f606', 'O:)':'1f607', 'O=)':'1f607', 'O:3':'1f607', 'B-)':'1f60e', '8-)':'1f60e', 'B-D':'1f60e', '8-D':'1f60e', '-_-':'1f611', '>:\\':'1f615',
'\':-(':'1f613', '>:/':'1f615', ':-/':'1f615', ':-.':'1f615', ':-P':'1f61b', ':Þ':'1f61b', ':-b':'1f61b', ':-O':'1f62e', 'O_O':'1f62e', '>:O':'1f62e',
'>:-(':'1f620', ':-X':'1f636', ':-#':'1f636', ':-)':'1f642', '(y)':'1f44d', '<3':'2764', ':D':'1f603', '=D':'1f603', ';)':'1f609', '*)':'1f609',
':\'-(':'1f622', ';]':'1f609', ';D':'1f609', ':*':'1f618', '=*':'1f618', ':(':'1f61e', ':[':'1f61e', '=(':'1f61e', ':@':'1f620', ';(':'1f622', 'D:':'1f628',
'O:-)':'1f607', ':$':'1f633', '=$':'1f633', '#)':'1f635', '%)':'1f635', 'X)':'1f635', 'B)':'1f60e', '8)':'1f60e', ':/':'1f615', ':\\':'1f615', '=/':'1f615',
'0:-3':'1f607', '=\\':'1f615', ':L':'1f615', '=L':'1f615', ':P':'1f61b', '=P':'1f61b', ':b':'1f61b', ':O':'1f62e', ':X':'1f636', ':#':'1f636', '=X':'1f636',
'0:-)':'1f607', '=#':'1f636', ':)':'1f642', '=]':'1f642', '=)':'1f642', ':]':'1f642'
'0;^)':'1f607',
'O;-)':'1f607',
'0;-)':'1f607',
'O:-3':'1f607',
'-__-':'1f611',
':-Þ':'1f61b',
'</3':'1f494',
':\')':'1f602',
':-D':'1f603',
'\':)':'1f605',
'\'=)':'1f605',
'\':D':'1f605',
'\'=D':'1f605',
'>:)':'1f606',
'>;)':'1f606',
'>=)':'1f606',
';-)':'1f609',
'*-)':'1f609',
';-]':'1f609',
';^)':'1f609',
'\':(':'1f613',
'\'=(':'1f613',
':-*':'1f618',
':^*':'1f618',
'>:P':'1f61c',
'X-P':'1f61c',
'>:[':'1f61e',
':-(':'1f61e',
':-[':'1f61e',
'>:(':'1f620',
':\'(':'1f622',
';-(':'1f622',
'>.<':'1f623',
'#-)':'1f635',
'%-)':'1f635',
'X-)':'1f635',
'\\0/':'1f646',
'\\O/':'1f646',
'0:3':'1f607',
'0:)':'1f607',
'O:)':'1f607',
'O=)':'1f607',
'O:3':'1f607',
'B-)':'1f60e',
'8-)':'1f60e',
'B-D':'1f60e',
'8-D':'1f60e',
'-_-':'1f611',
'>:\\':'1f615',
'>:/':'1f615',
':-/':'1f615',
':-.':'1f615',
':-P':'1f61b',
':Þ':'1f61b',
':-b':'1f61b',
':-O':'1f62e',
'O_O':'1f62e',
'>:O':'1f62e',
':-X':'1f636',
':-#':'1f636',
':-)':'1f642',
'(y)':'1f44d',
'<3':'2764',
':D':'1f603',
'=D':'1f603',
';)':'1f609',
'*)':'1f609',
';]':'1f609',
';D':'1f609',
':*':'1f618',
'=*':'1f618',
':(':'1f61e',
':[':'1f61e',
'=(':'1f61e',
':@':'1f620',
';(':'1f622',
'D:':'1f628',
':$':'1f633',
'=$':'1f633',
'#)':'1f635',
'%)':'1f635',
'X)':'1f635',
'B)':'1f60e',
'8)':'1f60e',
':/':'1f615',
':\\':'1f615',
'=/':'1f615',
'=\\':'1f615',
':L':'1f615',
'=L':'1f615',
':P':'1f61b',
'=P':'1f61b',
':b':'1f61b',
':O':'1f62e',
':X':'1f636',
':#':'1f636',
'=X':'1f636',
'=#':'1f636',
':)':'1f642',
'=]':'1f642',
'=)':'1f642',
':]':'1f642'
}; };
@ -202,6 +100,7 @@ converse.plugins.add('converse-emoji', {
} }
}); });
_converse.emojis = {};
_converse.api.promises.add('emojisInitialized', false); _converse.api.promises.add('emojisInitialized', false);
twemoji.default.base = _converse.emoji_image_path; twemoji.default.base = _converse.emoji_image_path;
@ -220,8 +119,6 @@ converse.plugins.add('converse-emoji', {
} }
}); });
_converse.emojis = {};
function getTonedEmojis () { function getTonedEmojis () {
if (!_converse.toned_emojis) { if (!_converse.toned_emojis) {
_converse.toned_emojis = _.uniq( _converse.toned_emojis = _.uniq(
@ -366,26 +263,29 @@ converse.plugins.add('converse-emoji', {
}); });
/************************ END Utils ************************/ /************************ END Utils ************************/
const { default: json } = await import(/*webpackChunkName: "emojis" */ './emojis.json'); async function initializeEmojis () {
_converse.emojis.json = json; if (_converse.emojis.json) {
_converse.emojis.categories = Object.keys(_converse.emojis.json); return;
_converse.emojis_map = _converse.emojis.categories.reduce((result, cat) => Object.assign(result, _converse.emojis.json[cat]), {}); }
_converse.emojis_list = Object.values(_converse.emojis_map); const { default: json } = await import(/*webpackChunkName: "emojis" */ './emojis.json');
_converse.emojis_list.sort((a, b) => a.sn < b.sn ? -1 : (a.sn > b.sn ? 1 : 0)); _converse.emojis.json = json;
_converse.emoji_shortnames = _converse.emojis_list.map(m => m.sn); _converse.emojis.categories = Object.keys(_converse.emojis.json);
_converse.emojis_map = _converse.emojis.categories.reduce((result, cat) => Object.assign(result, _converse.emojis.json[cat]), {});
_converse.emojis_list = Object.values(_converse.emojis_map);
_converse.emojis_list.sort((a, b) => a.sn < b.sn ? -1 : (a.sn > b.sn ? 1 : 0));
_converse.emoji_shortnames = _converse.emojis_list.map(m => m.sn);
const getShortNames = () => _converse.emoji_shortnames.map(s => s.replace(/[+]/g, "\\$&")).join('|'); const getShortNames = () => _converse.emoji_shortnames.map(s => s.replace(/[+]/g, "\\$&")).join('|');
_converse.emojis.shortnames_regex = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|("+getShortNames()+")", "gi"); _converse.emojis.shortnames_regex = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|("+getShortNames()+")", "gi");
_converse.emojis.toned = getTonedEmojis();
_converse.emojis.toned = getTonedEmojis(); /**
* Triggered once the JSON file representing emoji data has been
/** * fetched and its save to start calling emoji utility methods.
* Triggered once the JSON file representing emoji data has been * @event _converse#emojisInitialized
* fetched and its save to start calling emoji utility methods. */
* @event _converse#emojisInitialized _converse.api.trigger('emojisInitialized');
*/ }
_converse.api.trigger('emojisInitialized');
/************************ BEGIN Event Handlers ************************/ /************************ BEGIN Event Handlers ************************/
@ -395,6 +295,13 @@ converse.plugins.add('converse-emoji', {
delete _converse.emojipicker delete _converse.emojipicker
} }
}); });
_converse.api.listen.on('chatBoxesInitialized', () => {
_converse.chatboxes.on(
'add',
chat => (chat.get('type') !== _converse.CONTROLBOX_TYPE) && initializeEmojis()
);
});
/************************ END Event Handlers ************************/ /************************ END Event Handlers ************************/
} }
}); });

View File

@ -384,7 +384,7 @@ u.getResolveablePromise = function () {
wrapper.resolve = resolve; wrapper.resolve = resolve;
wrapper.reject = reject; wrapper.reject = reject;
}) })
_.assign(promise, wrapper); Object.assign(promise, wrapper);
promise.then( promise.then(
function (v) { function (v) {
promise.isResolved = true; promise.isResolved = true;

View File

@ -227,8 +227,9 @@
db_request.onsuccess = function () { db_request.onsuccess = function () {
const db = db_request.result; const db = db_request.result;
const bare_jid = "romeo@montague.lit"; const bare_jid = "romeo@montague.lit";
let store;
try { try {
const store= db.transaction([bare_jid], "readwrite").objectStore(bare_jid); store= db.transaction([bare_jid], "readwrite").objectStore(bare_jid);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
return promise.resolve(); return promise.resolve();