From eb99a019ed6eb689cd06cf595c06e8ffe4e120b1 Mon Sep 17 00:00:00 2001 From: Xavier Dubuc Date: Tue, 14 Jul 2020 12:36:27 +0000 Subject: [FIX] mail: fix inbox mark as read on single message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking on mark as read on a given message would move all messages in inbox to history instead of only selected message(s). This commit fix that behaviour so that only the selected message(s) move(s) to history. task-2284543 closes odoo/odoo#54688 X-original-commit: 3304b89fc799b979b028aa4c7efe902b2f5276c1 Signed-off-by: Alexandre Kühn (aku) --- .../messaging_notification_handler.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'addons/mail/static/src/models/messaging_notification_handler') diff --git a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js index f92521f248e..86cd5919b53 100644 --- a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js +++ b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js @@ -530,12 +530,20 @@ function factory(dependencies) { // 1. move messages from inbox to history // AKU TODO: flag other caches to invalidate // task-2171873 - inboxMailbox.messages.map(message => { - message.update({ - isNeedaction: false, - isHistory: true, - }); - }); + for (const message_id of message_ids) { + // We need to ignore all not yet known messages because we don't want them + // to be shown partially as they would be linked directly to mainCache + // Furthermore, server should not send back all message_ids marked as read + // but something like last read message_id or something like that. + // (just imagine you mark 1000 messages as read ... ) + const message = this.env.models['mail.message'].find(m => m.id === message_id); + if (message) { + message.update({ + isNeedaction: false, + isHistory: true, + }); + } + } // 2. remove "needaction" from channels let channels; -- cgit v1.2.3