Skip to content

Commit 622df6e

Browse files
committed
[FIX] website_{livechat}: hide chat hub using css only
When editing is enabled, the website loads both the backend and frontend assets. Until [1], this resulted in two sets of chat windows and bubbles being displayed. This commit is a follow-up to the above PR, maintaining the same behavior but relying only on styles. This avoids the need for cross-iframe or cross -window communication. [1]: odoo#212452 closes odoo#216765 X-original-commit: da79aae Signed-off-by: Alexandre Kühn (aku) <[email protected]> Signed-off-by: Matthieu Stockbauer (tsm) <[email protected]>
1 parent 7b413b0 commit 622df6e

File tree

11 files changed

+14
-140
lines changed

11 files changed

+14
-140
lines changed

addons/im_livechat/static/src/embed/frontend/livechat_root.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@ export class LivechatRoot extends Component {
1919
setup() {
2020
useSubEnv({ embedLivechat: true });
2121
this.overlayService = useService("overlay");
22-
this.store = useService("mail.store");
23-
this.store.embedLivechat = true;
2422
}
2523
}

addons/mail/static/src/core/common/chat_hub.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<templates xml:space="preserve">
33

44
<t t-name="mail.ChatHub">
5-
<div t-if="chatHub.show" class="o-mail-ChatHub d-print-none">
5+
<div class="o-mail-ChatHub d-print-none">
66

77
<t t-set="visibleChatWindows" t-value="chatHub.compact ? chatHub.opened.filter(({ bypassCompact }) => bypassCompact) : chatHub.opened "/>
88
<t t-foreach="visibleChatWindows" t-as="cw" t-key="cw.localId">

addons/mail/static/src/core/common/chat_hub_model.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ export class ChatHub extends Record {
146146
);
147147
}
148148

149-
get show() {
150-
return true;
151-
}
152-
153149
showConversations = fields.Attr(false, {
154150
compute() {
155151
return this.canShowOpened.length + this.canShowFolded.length > 0;

addons/website/static/src/client_actions/website_preview/website_builder_action.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ export class WebsiteBuilderClientAction extends Component {
7676
this.component = useComponent();
7777

7878
this.onKeydownRefresh = this._onKeydownRefresh.bind(this);
79-
this.env.services["mail.store"].isReady.then(() => {
80-
this.env.services["mail.store"].websiteBuilder.on = true;
81-
});
8279

8380
onMounted(() => {
8481
// You can't wait for rendering because the Builder depends on the
@@ -145,9 +142,6 @@ export class WebsiteBuilderClientAction extends Component {
145142
websiteSystrayRegistry.remove("website.WebsiteSystrayItem");
146143
this.websiteService.currentWebsiteId = null;
147144
websiteSystrayRegistry.trigger("EDIT-WEBSITE");
148-
this.env.services["mail.store"].isReady.then(() => {
149-
this.env.services["mail.store"].websiteBuilder.on = false;
150-
});
151145
});
152146

153147
effect(
@@ -168,14 +162,8 @@ export class WebsiteBuilderClientAction extends Component {
168162
websiteSystrayRegistry.trigger("EDIT-WEBSITE");
169163
document.querySelector(".o_builder_open .o_main_navbar").classList.add("d-none");
170164
}, 200);
171-
this.env.services["mail.store"].isReady.then(() => {
172-
this.env.services["mail.store"].websiteBuilder.editing = true;
173-
});
174165
} else {
175166
document.querySelector(".o_main_navbar")?.classList.remove("d-none");
176-
this.env.services["mail.store"].isReady.then(() => {
177-
this.env.services["mail.store"].websiteBuilder.editing = false;
178-
});
179167
}
180168
},
181169
() => [this.state.isEditing]
@@ -294,10 +282,6 @@ export class WebsiteBuilderClientAction extends Component {
294282
}
295283

296284
onIframeLoad(ev) {
297-
this.env.services["mail.store"].isReady.then(() => {
298-
this.env.services["mail.store"].websiteBuilder.iframeWindow =
299-
this.websiteContent.el.contentWindow;
300-
});
301285
this.websiteService.pageDocument = this.websiteContent.el.contentDocument;
302286
if (this.translation) {
303287
deleteQueryParam("edit_translations", this.websiteService.contentWindow, true);

addons/website/static/src/common/chat_hub_model_patch.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

addons/website/static/src/common/store_service_patch.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

addons/website/static/src/common/website_builder_model.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

addons/website_livechat/__manifest__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@
3030
"website_livechat/static/src/**/common/**/*",
3131
],
3232
'website.assets_wysiwyg': [
33-
'website_livechat/static/src/scss/**/*',
33+
"website/static/src/**/common/**/*",
3434
],
3535
'website.assets_editor': [
3636
'website_livechat/static/src/js/**/*',
3737
],
3838
'web.assets_frontend': [
39-
'website_livechat/static/src/patch/assets_frontend/website.scss',
39+
"website_livechat/static/src/**/common/**/*",
40+
'website_livechat/static/src/**/frontend/**/*',
4041
],
4142
'web.assets_backend': [
4243
"website_livechat/static/src/**/common/**/*",
4344
'website_livechat/static/src/**/*',
44-
('remove', 'website_livechat/static/src/scss/**/*'),
4545
],
4646
'web.assets_unit_tests': [
4747
'website_livechat/static/tests/**/*',
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
body.editor_enable .o-livechat-root {
2+
&::part(ChatHub),
3+
&::part(openChatButton) {
4+
visibility: hidden;
5+
}
6+
}
7+
8+
body:has(.o_website_preview):not(.o_builder_open) .o-mail-ChatHub {
9+
visibility: hidden;
10+
}

0 commit comments

Comments
 (0)