diff --git a/addons/mail/static/src/core/common/messaging_service.js b/addons/mail/static/src/core/common/messaging_service.js index 06602d3db13..b034cf6be19 100644 --- a/addons/mail/static/src/core/common/messaging_service.js +++ b/addons/mail/static/src/core/common/messaging_service.js @@ -11,7 +11,6 @@ import { markup, reactive } from "@odoo/owl"; import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { Deferred } from "@web/core/utils/concurrency"; -import { sprintf } from "@web/core/utils/strings"; /** * @typedef {Messaging} Messaging @@ -29,7 +28,6 @@ export class Messaging { this.orm = services.orm; /** @type {import("@mail/core/common/attachment_service").AttachmentService} */ this.attachmentService = services["mail.attachment"]; - this.notificationService = services.notification; /** @type {import("@mail/core/common/user_settings_service").UserSettings} */ this.userSettingsService = services["mail.user_settings"]; /** @type {import("@mail/core/common/thread_service").ThreadService} */ @@ -276,21 +274,6 @@ export class Messaging { } break; } - case "discuss.channel/unpin": { - const thread = - this.store.threads[createLocalId("discuss.channel", notif.payload.id)]; - if (thread) { - 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": { notif.payload.elements.map((message) => { @@ -468,7 +451,6 @@ export const messagingService = { "router", "bus_service", "im_status", - "notification", "mail.attachment", "mail.user_settings", "mail.thread", diff --git a/addons/mail/static/src/core/web/messaging_service_patch.js b/addons/mail/static/src/core/web/messaging_service_patch.js index 52fd4b37325..66e34576174 100644 --- a/addons/mail/static/src/core/web/messaging_service_patch.js +++ b/addons/mail/static/src/core/web/messaging_service_patch.js @@ -11,6 +11,7 @@ patch(Messaging.prototype, "mail/core/web", { this._super(env, services, initialThreadLocalId); /** @type {import("@mail/core/common/chat_window_service").ChatWindow} */ this.chatWindowService = services["mail.chat_window"]; + this.notificationService = services.notification; this.ui = services["ui"]; this.bus.subscribe("res.users/connection", async ({ partnerId, username }) => { // If the current user invited a new user, and the new user is @@ -44,5 +45,5 @@ patch(Messaging.prototype, "mail/core/web", { }); patch(messagingService, "mail/core/web", { - dependencies: [...messagingService.dependencies, "mail.chat_window", "ui"], + dependencies: [...messagingService.dependencies, "mail.chat_window", "notification", "ui"], }); diff --git a/addons/mail/static/src/discuss/core/common/discuss_core_common_service.js b/addons/mail/static/src/discuss/core/common/discuss_core_common_service.js index d7395ead99d..38b1a9e9918 100644 --- a/addons/mail/static/src/discuss/core/common/discuss_core_common_service.js +++ b/addons/mail/static/src/discuss/core/common/discuss_core_common_service.js @@ -94,6 +94,16 @@ export class DiscussCoreCommon { channel.messages.push(message); channel.transientMessages.push(message); }); + this.busService.subscribe("discuss.channel/unpin", (payload) => { + const thread = this.store.threads[createLocalId("discuss.channel", payload.id)]; + if (thread) { + thread.is_pinned = false; + this.notificationService.add( + sprintf(_t("You unpinned your conversation with %s"), thread.displayName), + { type: "info" } + ); + } + }); this.busService.subscribe("discuss.channel.member/fetched", (payload) => { const { channel_id, last_message_id, partner_id } = payload; const channel = this.store.threads[createLocalId("discuss.channel", channel_id)];