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