From 7c6a24d84f1a2f6fbf7896cfe6a3f3bf34bf32a6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Dufays Date: Thu, 27 Oct 2022 06:44:28 +0000 Subject: [PATCH] [FIX] mail: update message count when messages are deleted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a record was deleted, the related messages were removed in discuss front-end but the message counter was not updated. This solves this issue. Task-2960281 closes odoo/odoo#99371 Related: odoo/upgrade#3841 Signed-off-by: Warnon Aurélien (awa) --- .../src/models/messaging_notification_handler.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/mail/static/src/models/messaging_notification_handler.js b/addons/mail/static/src/models/messaging_notification_handler.js index 381b449d098..9acc57bfa7e 100644 --- a/addons/mail/static/src/models/messaging_notification_handler.js +++ b/addons/mail/static/src/models/messaging_notification_handler.js @@ -437,12 +437,26 @@ registerModel({ * @param {integer[]} param0.messag_ids */ _handleNotificationMessageDelete({ message_ids }) { + let deletedInboxMsg = 0; + let deletedStarredMsg = 0; for (const id of message_ids) { const message = this.messaging.models['Message'].findFromIdentifyingData({ id }); if (message) { + if (message.isNeedaction) { + deletedInboxMsg++; + } + if (message.isStarred) { + deletedStarredMsg++; + } message.delete(); } } + if (deletedInboxMsg) { + this.messaging.inbox.update({ counter: decrement(deletedInboxMsg) }); + } + if (deletedStarredMsg) { + this.messaging.starred.update({ counter: decrement(deletedStarredMsg) }); + } }, /** * @private