summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/thread_view/thread_view.js
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-11-02 11:31:13 +0000
committerSébastien Theys <seb@odoo.com>2020-11-02 11:31:13 +0000
commit03481fd3df9bc53a17ba884ad4029ae46d7e54bf (patch)
tree4e374aad0a7a6c845ee605b77cbe4e282efb7391 /addons/mail/static/src/models/thread_view/thread_view.js
parentb3e31f2680534382b048324cfcb8a6f6c457553f (diff)
[FIX] mail: handle transient messages with (un)seen notions
task-2343887 closes odoo/odoo#60906 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/thread_view/thread_view.js')
-rw-r--r--addons/mail/static/src/models/thread_view/thread_view.js40
1 files changed, 29 insertions, 11 deletions
diff --git a/addons/mail/static/src/models/thread_view/thread_view.js b/addons/mail/static/src/models/thread_view/thread_view.js
index 895732f8872..5c65e19c0f8 100644
--- a/addons/mail/static/src/models/thread_view/thread_view.js
+++ b/addons/mail/static/src/models/thread_view/thread_view.js
@@ -114,18 +114,29 @@ function factory(dependencies) {
* @returns {boolean}
*/
_computeThreadShouldBeSetAsSeen() {
- // FIXME condition should not be on "composer is focused" but "threadView is active"
- // See task-2277543
- const lastMessageIsVisible = this.lastVisibleMessage &&
- this.lastVisibleMessage === this.lastMessage;
- if (lastMessageIsVisible && this.hasComposerFocus && this.thread) {
- this.thread.markAsSeen(this.lastMessage.id).catch(e => {
- // prevent crash when executing compute during destroy
- if (!(e instanceof RecordDeletedError)) {
- throw e;
- }
- });
+ if (!this.thread) {
+ return;
+ }
+ if (!this.thread.lastNonTransientMessage) {
+ return;
+ }
+ if (!this.lastVisibleMessage) {
+ return;
+ }
+ if (this.lastVisibleMessage !== this.lastMessage) {
+ return;
}
+ if (!this.hasComposerFocus) {
+ // FIXME condition should not be on "composer is focused" but "threadView is active"
+ // See task-2277543
+ return;
+ }
+ this.thread.markAsSeen(this.thread.lastNonTransientMessage).catch(e => {
+ // prevent crash when executing compute during destroy
+ if (!(e instanceof RecordDeletedError)) {
+ throw e;
+ }
+ });
}
/**
@@ -233,6 +244,12 @@ function factory(dependencies) {
related: 'thread.lastMessage',
}),
/**
+ * Serves as compute dependency.
+ */
+ lastNonTransientMessage: many2one('mail.message', {
+ related: 'thread.lastNonTransientMessage',
+ }),
+ /**
* Most recent message in this ThreadView that has been shown to the
* current partner in the currently displayed thread cache.
*/
@@ -329,6 +346,7 @@ function factory(dependencies) {
dependencies: [
'hasComposerFocus',
'lastMessage',
+ 'lastNonTransientMessage',
'lastVisibleMessage',
'threadCache',
],