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