Commit ccbf0490 authored by JC Brand's avatar JC Brand

emoji: raise an error if `getShortnameReferences` is called too soon

parent 49cda749
......@@ -12,6 +12,7 @@ import { html } from 'lit-html';
const u = converse.env.utils;
converse.emojis = {
'initialized': false,
'initialized_promise': u.getResolveablePromise()
};
......@@ -145,6 +146,12 @@ export function getEmojiMarkup (data, options={unicode_only: false, add_title_wr
export function getShortnameReferences (text) {
if (!converse.emojis.initialized) {
throw new Error(
'getShortnameReferences called before emojis are initialized. '+
'To avoid this problem, first await the converse.emojis.initilaized_promise.'
);
}
const references = [...text.matchAll(shortnames_regex)];
return references.map(ref => {
const cp = converse.emojis.by_sn[ref[0]].cp;
......
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