From 73db2d735f9f474cf533115101c0fce515b21232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 15 Mar 2022 15:38:45 +0000 Subject: [PATCH] [IMP] mail: turn 'MessageView/hasAuthorOpenChat' into field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-2793280 closes odoo/odoo#86466 Signed-off-by: Alexandre Kühn (aku) --- .../static/src/components/message/message.js | 24 +---------------- .../static/src/components/message/message.xml | 4 +-- addons/mail/static/src/models/message_view.js | 26 +++++++++++++++++++ 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/addons/mail/static/src/components/message/message.js b/addons/mail/static/src/components/message/message.js index f5e97322185..85732388e8c 100644 --- a/addons/mail/static/src/components/message/message.js +++ b/addons/mail/static/src/components/message/message.js @@ -95,28 +95,6 @@ export class Message extends Component { return this.messageView.message.date.format(getLangDatetimeFormat()); } - /** - * Determines whether author open chat feature is enabled on message. - * - * @returns {boolean} - */ - get hasAuthorOpenChat() { - if (this.messaging.currentGuest) { - return false; - } - if (!this.messageView.message.author) { - return false; - } - if ( - this.messageView.threadView && - this.messageView.threadView.thread && - this.messageView.threadView.thread.correspondent === this.messageView.message.author - ) { - return false; - } - return true; - } - /** * Whether the message is "active", ie: hovered or clicked, and should * display additional things (date in sidebar, message actions, etc.) @@ -406,7 +384,7 @@ export class Message extends Component { */ _onClickAuthorAvatar(ev) { markEventHandled(ev, 'Message.ClickAuthorAvatar'); - if (!this.hasAuthorOpenChat) { + if (!this.messageView.hasAuthorOpenChat) { return; } this.messageView.message.author.openChat(); diff --git a/addons/mail/static/src/components/message/message.xml b/addons/mail/static/src/components/message/message.xml index b50bb7d5655..93713fe4687 100644 --- a/addons/mail/static/src/components/message/message.xml +++ b/addons/mail/static/src/components/message/message.xml @@ -29,7 +29,7 @@
- Avatar + Avatar diff --git a/addons/mail/static/src/models/message_view.js b/addons/mail/static/src/models/message_view.js index cc56bfd5c75..b81f09ae843 100644 --- a/addons/mail/static/src/models/message_view.js +++ b/addons/mail/static/src/models/message_view.js @@ -117,6 +117,26 @@ registerModel({ } return clear(); }, + /** + * @private + * @returns {boolean} + */ + _computeHasAuthorOpenChat() { + if (this.messaging.currentGuest) { + return false; + } + if (!this.message.author) { + return false; + } + if ( + this.threadView && + this.threadView.thread && + this.threadView.thread.correspondent === this.message.author + ) { + return false; + } + return true; + }, /** * @private * @returns {FieldCommand} @@ -183,6 +203,12 @@ registerModel({ compute: '_computeExtraClass', default: '', }), + /** + * Determines whether author open chat feature is enabled on message. + */ + hasAuthorOpenChat: attr({ + compute: '_computeHasAuthorOpenChat', + }), /** * id of the current timeout that will reset isHighlighted to false. */