From 57ac4a4dca477e4372a9956c46caba1df0ff2438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Tue, 22 Mar 2022 16:25:49 +0000 Subject: [PATCH] [IMP] mail: prevent useless render of message view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid observing the last message view just for checking the state of self. task-2800990 closes odoo/odoo#87003 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/models/message_view.js | 10 +++++++++- addons/mail/static/src/models/thread_view.js | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/models/message_view.js b/addons/mail/static/src/models/message_view.js index 3da42b18b48..8c240241bdd 100644 --- a/addons/mail/static/src/models/message_view.js +++ b/addons/mail/static/src/models/message_view.js @@ -40,7 +40,7 @@ registerModel({ this.highlight(); this.update({ doHighlight: clear() }); } - if (this.threadView && this.threadView.lastMessageView === this && this.component && this.component.isPartiallyVisible()) { + if (this.threadViewOwnerAsLastMessageView && this.component && this.component.isPartiallyVisible()) { this.threadView.handleVisibleMessage(this.message); } }, @@ -268,5 +268,13 @@ registerModel({ inverse: 'messageViews', readonly: true, }), + /** + * States whether this message view is the last one of its thread view. + * Computed from inverse relation. + */ + threadViewOwnerAsLastMessageView: one('ThreadView', { + inverse: 'lastMessageView', + readonly: true, + }), }, }); diff --git a/addons/mail/static/src/models/thread_view.js b/addons/mail/static/src/models/thread_view.js index 81f6a71b40d..52afd7eed16 100644 --- a/addons/mail/static/src/models/thread_view.js +++ b/addons/mail/static/src/models/thread_view.js @@ -438,6 +438,8 @@ registerModel({ }), lastMessageView: one('MessageView', { compute: '_computeLastMessageView', + inverse: 'threadViewOwnerAsLastMessageView', + readonly: true, }), /** * Most recent message in this ThreadView that has been shown to the