From 01f03b1e1927e66d3deddfa6164f2e930183be55 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 27 Oct 2023 10:47:16 +0200 Subject: [PATCH] [IMP] mail: do not wait for init_messaging at webclient startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The messaging service starts synchronously and exposes a promise isReady that is resolved when the call to init_messaging is done. This is good as this call thus doesn't slow down the services startup and thus the webclient mount. Unfortunately, the ChatWindowContainer, which is a main component, i.e. a child of the WebClient, waits for that promise in its onWillStart. As a consequence, the webclient can't be mounted until the rpc returns, which can take a while (in odoo.com, this rpc lasts ~500ms). The chat windows being "peripherical components", there's no reason to block the whole application for them. Instead, the webclient can be mounted, and when they are ready, the chat windows can be rendered. This is what this commit does. Back-port of https://github.com/odoo/odoo/pull/139750/ closes odoo/odoo#140056 Signed-off-by: Sébastien Theys (seb) --- .../static/src/core/common/chat_window_container.js | 13 ++----------- .../src/core/common/chat_window_container.xml | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/addons/mail/static/src/core/common/chat_window_container.js b/addons/mail/static/src/core/common/chat_window_container.js index 1bb3a354c00..6171dcfa2f4 100644 --- a/addons/mail/static/src/core/common/chat_window_container.js +++ b/addons/mail/static/src/core/common/chat_window_container.js @@ -7,15 +7,7 @@ import { CHAT_WINDOW_WIDTH, } from "@mail/core/common/chat_window_service"; -import { - Component, - onWillStart, - useExternalListener, - useState, - onMounted, - useRef, - useEffect, -} from "@odoo/owl"; +import { Component, useExternalListener, useState, onMounted, useRef, useEffect } from "@odoo/owl"; import { browser } from "@web/core/browser/browser"; import { Dropdown } from "@web/core/dropdown/dropdown"; @@ -48,9 +40,8 @@ export class ChatWindowContainer extends Component { this.hiddenMenuRef = useRef("hiddenMenu"); useEffect( () => this.setHiddenMenuOffset(), - () => [this.chatWindowService.hidden] + () => [this.chatWindowService.hidden, this.store.isMessagingReady] ); - onWillStart(() => this.messaging.isReady); onMounted(() => this.setHiddenMenuOffset()); this.onResize(); diff --git a/addons/mail/static/src/core/common/chat_window_container.xml b/addons/mail/static/src/core/common/chat_window_container.xml index ca4fe096b88..23504c63224 100644 --- a/addons/mail/static/src/core/common/chat_window_container.xml +++ b/addons/mail/static/src/core/common/chat_window_container.xml @@ -2,7 +2,7 @@ -
+