diff --git a/addons/mail/static/src/core/common/mail_core_common_service.js b/addons/mail/static/src/core/common/mail_core_common_service.js index cee4c54a6b5..877b31b5c4e 100644 --- a/addons/mail/static/src/core/common/mail_core_common_service.js +++ b/addons/mail/static/src/core/common/mail_core_common_service.js @@ -1,6 +1,7 @@ /* @odoo-module */ import { LinkPreview } from "@mail/core/common/link_preview_model"; +import { removeFromArrayWithPredicate } from "@mail/utils/common/arrays"; import { markup, reactive } from "@odoo/owl"; @@ -27,6 +28,16 @@ export class MailCoreCommon { setup() { this.messagingService.isReady.then(() => { + this.busService.subscribe("mail.link.preview/delete", (payload) => { + const { id, message_id } = payload; + const message = this.store.messages[message_id]; + if (message) { + removeFromArrayWithPredicate( + message.linkPreviews, + (linkPreview) => linkPreview.id === id + ); + } + }); this.busService.subscribe("mail.record/insert", (payload) => { if (payload.Thread) { this.threadService.insert(payload.Thread); diff --git a/addons/mail/static/src/core/common/messaging_service.js b/addons/mail/static/src/core/common/messaging_service.js index c3aedc4391b..6ca44805732 100644 --- a/addons/mail/static/src/core/common/messaging_service.js +++ b/addons/mail/static/src/core/common/messaging_service.js @@ -129,18 +129,6 @@ export class Messaging { handleNotification(notifications) { for (const notif of notifications) { switch (notif.type) { - case "mail.link.preview/delete": - { - const { id, message_id } = notif.payload; - const message = this.store.messages[message_id]; - if (message) { - removeFromArrayWithPredicate( - message.linkPreviews, - (linkPreview) => linkPreview.id === id - ); - } - } - break; case "mail.message/inbox": { const data = Object.assign(notif.payload, { body: markup(notif.payload.body) }); const message = this.messageService.insert(data);