From 7d180a0bc064ec0f936321c54ce97e33be3ce95f Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Fri, 14 Jul 2023 13:21:15 +0000 Subject: [PATCH] [FIX] mail: remove return in handle notification loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, some notifications handler were using `return`. The issue is that this will exit the notification processing loop preventing further notifications to be processed. In practice, this scenario is limited since notifications come by small batches but it could be an issue. closes odoo/odoo#128606 X-original-commit: e8fbc26716917b1066b9002010662d41aaeacbf0 Signed-off-by: Sébastien Theys (seb) --- .../src/core/common/messaging_service.js | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/addons/mail/static/src/core/common/messaging_service.js b/addons/mail/static/src/core/common/messaging_service.js index 4a45d66f952..10e1288e780 100644 --- a/addons/mail/static/src/core/common/messaging_service.js +++ b/addons/mail/static/src/core/common/messaging_service.js @@ -183,7 +183,7 @@ export class Messaging { // "discuss.channel/leave" and the // "discuss.channel/new_message" notifications come from // the bus as a batch. - return; + break; } this._handleNotificationNewMessage(notif); break; @@ -375,28 +375,29 @@ export class Messaging { const { channel_id, last_message_id, partner_id } = notif.payload; const channel = this.store.threads[createLocalId("discuss.channel", channel_id)]; - if (!channel) { - return; - } - const seenInfo = channel.seenInfos.find( - (seenInfo) => seenInfo.partner.id === partner_id - ); - if (seenInfo) { - seenInfo.lastFetchedMessage = { id: last_message_id }; + if (channel) { + const seenInfo = channel.seenInfos.find( + (seenInfo) => seenInfo.partner.id === partner_id + ); + if (seenInfo) { + seenInfo.lastFetchedMessage = { id: last_message_id }; + } } break; } case "discuss.channel/unpin": { const thread = this.store.threads[createLocalId("discuss.channel", notif.payload.id)]; - if (!thread) { - return; + if (thread) { + thread.is_pinned = false; + this.notificationService.add( + sprintf( + _t("You unpinned your conversation with %s"), + thread.displayName + ), + { type: "info" } + ); } - thread.is_pinned = false; - this.notificationService.add( - sprintf(_t("You unpinned your conversation with %s"), thread.displayName), - { type: "info" } - ); break; } case "mail.message/notification_update": @@ -425,10 +426,9 @@ export class Messaging { }); } const attachment = this.store.attachments[attachmentId]; - if (!attachment) { - return; + if (attachment) { + this.attachmentService.remove(attachment); } - this.attachmentService.remove(attachment); } break; }