Wait for emojis to be initialized before sending a message
This commit is contained in:
parent
53521c2236
commit
3d19def3e7
@ -845,6 +845,7 @@ const ChatBox = ModelWithContact.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getOutgoingMessageAttributes (attrs) {
|
async getOutgoingMessageAttributes (attrs) {
|
||||||
|
await api.emojis.initialize();
|
||||||
const is_spoiler = !!this.get('composing_spoiler');
|
const is_spoiler = !!this.get('composing_spoiler');
|
||||||
const origin_id = u.getUniqueId();
|
const origin_id = u.getUniqueId();
|
||||||
const text = attrs?.body;
|
const text = attrs?.body;
|
||||||
|
@ -94,7 +94,7 @@ export function getShortnameReferences (text) {
|
|||||||
if (!converse.emojis.initialized) {
|
if (!converse.emojis.initialized) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'getShortnameReferences called before emojis are initialized. '+
|
'getShortnameReferences called before emojis are initialized. '+
|
||||||
'To avoid this problem, first await the converse.emojis.initilaized_promise.'
|
'To avoid this problem, first await the converse.emojis.initialized_promise'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const references = [...text.matchAll(converse.emojis.shortnames_regex)].filter(ref => ref[0].length > 0);
|
const references = [...text.matchAll(converse.emojis.shortnames_regex)].filter(ref => ref[0].length > 0);
|
||||||
@ -207,4 +207,3 @@ Object.assign(u, {
|
|||||||
isOnlyEmojis,
|
isOnlyEmojis,
|
||||||
shortnamesToUnicode,
|
shortnamesToUnicode,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -981,6 +981,7 @@ const ChatRoomMixin = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getOutgoingMessageAttributes (attrs) {
|
async getOutgoingMessageAttributes (attrs) {
|
||||||
|
await api.emojis.initialize();
|
||||||
const is_spoiler = this.get('composing_spoiler');
|
const is_spoiler = this.get('composing_spoiler');
|
||||||
let text = '', references;
|
let text = '', references;
|
||||||
if (attrs?.body) {
|
if (attrs?.body) {
|
||||||
|
@ -42,7 +42,8 @@ describe("The <converse-muc> component", function () {
|
|||||||
const muc_jid = 'lounge@montague.lit';
|
const muc_jid = 'lounge@montague.lit';
|
||||||
const nick = 'romeo';
|
const nick = 'romeo';
|
||||||
|
|
||||||
const muc_creation_promise = await api.rooms.open(muc_jid, {nick, 'hidden': true}, false);
|
|
||||||
|
const muc_creation_promise = api.rooms.open(muc_jid, {nick, 'hidden': true}, false);
|
||||||
await mock.getRoomFeatures(_converse, muc_jid, []);
|
await mock.getRoomFeatures(_converse, muc_jid, []);
|
||||||
await mock.receiveOwnMUCPresence(_converse, muc_jid, nick);
|
await mock.receiveOwnMUCPresence(_converse, muc_jid, nick);
|
||||||
await muc_creation_promise;
|
await muc_creation_promise;
|
||||||
@ -59,6 +60,7 @@ describe("The <converse-muc> component", function () {
|
|||||||
span_el.classList.add('conversejs');
|
span_el.classList.add('conversejs');
|
||||||
span_el.classList.add('converse-embedded');
|
span_el.classList.add('converse-embedded');
|
||||||
|
|
||||||
|
|
||||||
const muc_el = document.createElement('converse-muc');
|
const muc_el = document.createElement('converse-muc');
|
||||||
muc_el.classList.add('chatbox');
|
muc_el.classList.add('chatbox');
|
||||||
muc_el.classList.add('chatroom');
|
muc_el.classList.add('chatroom');
|
||||||
@ -73,8 +75,10 @@ describe("The <converse-muc> component", function () {
|
|||||||
const message = await u.waitUntil(() => muc_el.querySelector('converse-chat-message'));
|
const message = await u.waitUntil(() => muc_el.querySelector('converse-chat-message'));
|
||||||
expect(message.model.get('body')).toBe('hello from the lounge!');
|
expect(message.model.get('body')).toBe('hello from the lounge!');
|
||||||
|
|
||||||
|
_converse.connection.sent_stanzas = [];
|
||||||
|
|
||||||
const muc2_jid = 'bar@montague.lit';
|
const muc2_jid = 'bar@montague.lit';
|
||||||
const muc2_creation_promise = await api.rooms.open(muc2_jid, {nick, 'hidden': true}, false);
|
const muc2_creation_promise = api.rooms.open(muc2_jid, {nick, 'hidden': true}, false);
|
||||||
await mock.getRoomFeatures(_converse, muc2_jid, []);
|
await mock.getRoomFeatures(_converse, muc2_jid, []);
|
||||||
await mock.receiveOwnMUCPresence(_converse, muc2_jid, nick);
|
await mock.receiveOwnMUCPresence(_converse, muc2_jid, nick);
|
||||||
await muc2_creation_promise;
|
await muc2_creation_promise;
|
||||||
|
Loading…
Reference in New Issue
Block a user