diff options
| author | Xavier Dubuc <xdu@odoo.com> | 2020-09-29 14:39:46 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2020-09-29 16:41:14 +0000 |
| commit | 0df66708defd0fcb288979b1431d8180831e43d3 (patch) | |
| tree | f6dc459fef07fd5f0d48213277d9c0920bfbccd1 /addons/mail/static/src/models/thread/thread.js | |
| parent | ec880af6aa091ba5f5cc39e754c7266d2488cba7 (diff) | |
[FIX] mail: do not show new messages separator for own messages
Also fix compute of local counter in some specific situations.
task-2341740
closes odoo/odoo#58855
X-original-commit: 7d1878ff8a4757d1626d694b624f79e597ddd717
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/thread/thread.js')
| -rw-r--r-- | addons/mail/static/src/models/thread/thread.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/addons/mail/static/src/models/thread/thread.js b/addons/mail/static/src/models/thread/thread.js index 4ad43577b1f..837de254d9d 100644 --- a/addons/mail/static/src/models/thread/thread.js +++ b/addons/mail/static/src/models/thread/thread.js @@ -1108,6 +1108,11 @@ function factory(dependencies) { if (!this.lastSeenByCurrentPartnerMessageId) { return this.serverMessageUnreadCounter; } + // if server knows more messages than the client knows then we just + // need to trust him + if (this.serverLastMessageId > this.lastSeenByCurrentPartnerMessageId) { + return this.serverMessageUnreadCounter; + } const firstMessage = this.orderedMessages[0]; // if the lastSeenByCurrentPartnerMessageId is not known (not fetched), then we // need to rely on server value to determine the amount of unread @@ -1115,15 +1120,15 @@ function factory(dependencies) { // serverMessageUnreadCounter if (this.lastSeenByCurrentPartnerMessageId < firstMessage.id) { const fetchedNotSeenMessages = this.orderedMessages.filter(message => - message.id > this.serverLastMessageId + message.id > this.serverLastMessageId && message.author !== this.env.messaging.currentPartner ); return this.serverMessageUnreadCounter + fetchedNotSeenMessages.length; } // lastSeenByCurrentPartnerMessageId is a known message, // then we can forget serverMessageUnreadCounter - const maxId = Math.max(this.serverLastMessageId, this.lastSeenByCurrentPartnerMessageId); + const maxId = this.lastSeenByCurrentPartnerMessageId; return this.orderedMessages.reduce( - (acc, message) => acc + (message.id > maxId ? 1 : 0), + (acc, message) => acc + ((message.id > maxId && message.author !== this.env.messaging.currentPartner) ? 1 : 0), 0 ); } @@ -1544,6 +1549,7 @@ function factory(dependencies) { dependencies: [ 'lastMessage', 'lastSeenByCurrentPartnerMessageId', + 'messagingCurrentPartner', 'orderedMessages', 'serverLastMessageId', 'serverMessageUnreadCounter', |
