chat: New chatSendMessage client-side hook

This commit is contained in:
Richard Hansen 2021-10-26 02:08:14 -04:00
parent 4c2f7f9a11
commit 9fbd2e5c3d
4 changed files with 71 additions and 3 deletions

View file

@ -100,10 +100,12 @@ exports.chat = (() => {
}
}
},
send() {
async send() {
const text = $('#chatinput').val();
if (text.replace(/\s+/, '').length === 0) return;
this._pad.collabClient.sendMessage({type: 'CHAT_MESSAGE', message: new ChatMessage(text)});
const message = new ChatMessage(text);
await hooks.aCallAll('chatSendMessage', Object.freeze({message}));
this._pad.collabClient.sendMessage({type: 'CHAT_MESSAGE', message});
$('#chatinput').val('');
},
async addMessage(msg, increment, isHistoryAdd) {