chat: Promisify addMessage()

This commit is contained in:
Richard Hansen 2021-10-25 19:51:37 -04:00
parent 3f7f629eeb
commit caac4bf711

View file

@ -105,7 +105,7 @@ exports.chat = (() => {
this._pad.collabClient.sendMessage({type: 'CHAT_MESSAGE', text}); this._pad.collabClient.sendMessage({type: 'CHAT_MESSAGE', text});
$('#chatinput').val(''); $('#chatinput').val('');
}, },
addMessage(msg, increment, isHistoryAdd) { async addMessage(msg, increment, isHistoryAdd) {
// correct the time // correct the time
msg.time += this._pad.clientTimeOffset; msg.time += this._pad.clientTimeOffset;
@ -161,8 +161,7 @@ exports.chat = (() => {
ctx.sticky = true; ctx.sticky = true;
} }
// Call chat message hook await hooks.aCallAll('chatNewMessage', ctx);
hooks.aCallAll('chatNewMessage', ctx, () => {
const cls = authorClass(ctx.author); const cls = authorClass(ctx.author);
const chatMsg = $('<p>') const chatMsg = $('<p>')
.attr('data-authorId', ctx.author) .attr('data-authorId', ctx.author)
@ -203,7 +202,6 @@ exports.chat = (() => {
} }
} }
if (!isHistoryAdd) this.scrollDown(); if (!isHistoryAdd) this.scrollDown();
});
}, },
init(pad) { init(pad) {
this._pad = pad; this._pad = pad;