From c89853c219a27ff7d349036fd4d99e1f82223e76 Mon Sep 17 00:00:00 2001 From: "Didier (did)" Date: Fri, 2 Sep 2022 12:52:14 +0000 Subject: [PATCH] [IMP] mail: move command code out of postMessage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes odoo/odoo#99489 Signed-off-by: Sébastien Theys (seb) --- .../mail/static/src/models/composer_view.js | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/addons/mail/static/src/models/composer_view.js b/addons/mail/static/src/models/composer_view.js index fb837acdb21..8b5a1ac2371 100644 --- a/addons/mail/static/src/models/composer_view.js +++ b/addons/mail/static/src/models/composer_view.js @@ -548,19 +548,6 @@ registerModel({ */ async postMessage() { const composer = this.composer; - if (composer.thread.model === 'mail.channel') { - const command = this._getCommandFromText(composer.textInputContent); - if (command) { - await command.execute({ channel: composer.thread, body: composer.textInputContent }); - if (composer.exists()) { - composer._reset(); - } - return; - } - } - if (composer.thread.channel) { - composer.thread.unregisterCurrentPartnerIsTyping({ immediateNotify: true }); - } const postData = this._getMessageData(); const params = { 'post_data': postData, @@ -656,7 +643,7 @@ registerModel({ * Sending of the message could be aborted if it cannot be posted like if there are attachments * currently uploading or if there is no text content and no attachments. */ - sendMessage() { + async sendMessage() { if (!this.composer.canPostMessage) { if (this.composer.hasUploadingAttachment) { this.messaging.notify({ @@ -670,6 +657,17 @@ registerModel({ this.updateMessage(); return; } + if (this.composer.thread.channel) { + const command = this._getCommandFromText(this.composer.textInputContent); + if (command) { + await command.execute({ channel: this.composer.thread, body: this.composer.textInputContent }); + if (this.composer.exists()) { + this.composer._reset(); + } + return; + } + this.composer.thread.unregisterCurrentPartnerIsTyping({ immediateNotify: true }); + } this.postMessage(); }, /**