[REF] im_livechat: remove messaging service patch
Part of task-3265211 Part-of: odoo/odoo#129583
This commit is contained in:
@@ -133,6 +133,7 @@ Help your customers with this chat, and analyse their feedback.
|
||||
('remove', 'web/static/tests/mock_server_tests.js'),
|
||||
('remove', 'im_livechat/static/**'),
|
||||
'im_livechat/static/tests/helpers/**',
|
||||
('remove', 'im_livechat/static/tests/helpers/**/web/**'),
|
||||
'im_livechat/static/src/embed/**/*',
|
||||
('remove', 'im_livechat/static/src/embed/external/**/*'),
|
||||
],
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { Messaging } from "@mail/core/common/messaging_service";
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(Messaging.prototype, "im_livechat", {
|
||||
initMessagingCallback(data) {
|
||||
this._super(data);
|
||||
if (data.current_user_settings?.is_discuss_sidebar_category_livechat_open) {
|
||||
this.store.discuss.livechat.isOpen = true;
|
||||
}
|
||||
},
|
||||
_handleNotificationRecordInsert(notif) {
|
||||
this._super(notif);
|
||||
const { "res.users.settings": settings } = notif.payload;
|
||||
if (settings) {
|
||||
this.store.discuss.livechat.isOpen =
|
||||
settings.is_discuss_sidebar_category_livechat_open ??
|
||||
this.store.discuss.livechat.isOpen;
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { reactive } from "@odoo/owl";
|
||||
|
||||
import { registry } from "@web/core/registry";
|
||||
|
||||
export class LivechatCoreWeb {
|
||||
constructor(env, services) {
|
||||
Object.assign(this, {
|
||||
busService: services.bus_service,
|
||||
});
|
||||
/** @type {import("@mail/core/common/messaging_service").Messaging} */
|
||||
this.messagingService = services["mail.messaging"];
|
||||
/** @type {import("@mail/core/common/store_service").Store} */
|
||||
this.store = services["mail.store"];
|
||||
}
|
||||
|
||||
setup() {
|
||||
this.messagingService.isReady.then((data) => {
|
||||
if (data.current_user_settings?.is_discuss_sidebar_category_livechat_open) {
|
||||
this.store.discuss.livechat.isOpen = true;
|
||||
}
|
||||
this.busService.subscribe("mail.record/insert", (payload) => {
|
||||
const { "res.users.settings": settings } = payload;
|
||||
if (settings) {
|
||||
this.store.discuss.livechat.isOpen =
|
||||
settings.is_discuss_sidebar_category_livechat_open ??
|
||||
this.store.discuss.livechat.isOpen;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const livechatCoreWeb = {
|
||||
dependencies: ["bus_service", "mail.messaging", "mail.store"],
|
||||
start(env, services) {
|
||||
const livechatCoreWeb = reactive(new LivechatCoreWeb(env, services));
|
||||
livechatCoreWeb.setup();
|
||||
return livechatCoreWeb;
|
||||
},
|
||||
};
|
||||
|
||||
registry.category("services").add("im_livechat.core.web", livechatCoreWeb);
|
||||
@@ -0,0 +1,16 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { livechatCoreWeb } from "@im_livechat/core/web/livechat_core_web_service";
|
||||
|
||||
import { setupManager } from "@mail/../tests/helpers/webclient_setup";
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(setupManager, "im_livechat/core/web", {
|
||||
setupServices(...args) {
|
||||
return {
|
||||
...this._super(...args),
|
||||
"im_livechat.core.web": livechatCoreWeb,
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user