From ea3008cc4970edc4628ab80136cf2ef761ef2e1e Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Wed, 17 May 2023 03:42:18 +0000 Subject: [PATCH] [IMP] mail, im_livechat: use ui service instead of `store.isSmall` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since [1], the ui service is reactive which removes the needs for the `mail.store` service to maintain a reactive version of `isSmall`. This PR replaces the use of `store.isSmall` as well as `env.isSmall` by the ui service. 1: https://github.com/odoo/odoo/pull/121343 closes odoo/odoo#121590 Signed-off-by: Sébastien Theys (seb) --- .../static/src/core/thread_service_patch.js | 2 +- .../static/src/legacy/core_models/device.js | 2 +- .../static/src/attachments/attachment_viewer.js | 2 ++ .../static/src/attachments/attachment_viewer.xml | 4 ++-- addons/mail/static/src/composer/composer.js | 1 + addons/mail/static/src/composer/composer.xml | 8 ++++---- addons/mail/static/src/core/store_service.js | 6 ++---- addons/mail/static/src/core/thread_service.js | 4 +++- .../static/src/core_ui/message_reaction_menu.js | 1 + .../static/src/core_ui/message_reaction_menu.xml | 2 +- .../mail/static/src/core_ui/message_reactions.js | 3 ++- addons/mail/static/src/core_ui/thread.js | 1 + addons/mail/static/src/core_ui/thread.xml | 2 +- .../mail/static/src/discuss/channel_invitation.js | 3 ++- .../static/src/discuss/web/chat_window_patch.xml | 2 +- addons/mail/static/src/discuss_app/discuss.js | 1 + addons/mail/static/src/discuss_app/discuss.xml | 10 +++++----- .../src/discuss_app/pinned_messages_panel.js | 6 ++++-- .../src/discuss_app/pinned_messages_panel.xml | 4 ++-- .../src/views/activity/activity_controller.js | 3 ++- .../src/views/activity/activity_controller.xml | 2 +- .../mail/static/src/web/activity/activity_menu.js | 3 ++- .../mail/static/src/web/activity/activity_menu.xml | 4 ++-- .../mail/static/src/web/chat_window/chat_window.js | 7 ++++--- .../static/src/web/chat_window/chat_window.xml | 14 +++++++------- .../src/web/chat_window/chat_window_container.js | 1 + .../src/web/chat_window/chat_window_container.xml | 4 ++-- .../src/web/chat_window/chat_window_service.js | 11 ++++++----- .../static/src/web/discuss_app/discuss_patch.xml | 4 ++-- .../src/web/messaging_menu/messaging_menu.js | 3 ++- .../src/web/messaging_menu/messaging_menu.xml | 14 +++++++------- .../mail/static/src/web/messaging_service_patch.js | 5 +++-- addons/mail/static/src/web/thread_service_patch.js | 2 +- .../static/tests/chat_window/chat_window_tests.js | 7 +++++-- addons/mail/static/tests/helpers/test_utils.js | 2 +- 35 files changed, 85 insertions(+), 65 deletions(-) diff --git a/addons/im_livechat/static/src/core/thread_service_patch.js b/addons/im_livechat/static/src/core/thread_service_patch.js index 7f11f919dd1..fdd07df58f9 100644 --- a/addons/im_livechat/static/src/core/thread_service_patch.js +++ b/addons/im_livechat/static/src/core/thread_service_patch.js @@ -27,7 +27,7 @@ patch(ThreadService.prototype, "im_livechat", { */ setDiscussThread(thread, pushState) { this._super(thread, pushState); - if (this.store.isSmall && thread.type === "livechat") { + if (this.ui.isSmall && thread.type === "livechat") { this.store.discuss.activeTab = "livechat"; } }, diff --git a/addons/im_livechat/static/src/legacy/core_models/device.js b/addons/im_livechat/static/src/legacy/core_models/device.js index f30234f75af..d11c54ca3fb 100644 --- a/addons/im_livechat/static/src/legacy/core_models/device.js +++ b/addons/im_livechat/static/src/legacy/core_models/device.js @@ -32,7 +32,7 @@ Model({ globalWindowInnerHeight: this.messaging.browser.innerHeight, globalWindowInnerWidth: this.messaging.browser.innerWidth, isMobileDevice: isMobileOS(), - isSmall: this.env.isSmall, + isSmall: this.env.services.ui.isSmall, sizeClass: this.env.services.ui.size, }); }, diff --git a/addons/mail/static/src/attachments/attachment_viewer.js b/addons/mail/static/src/attachments/attachment_viewer.js index ad6609235ce..ece3502b87b 100644 --- a/addons/mail/static/src/attachments/attachment_viewer.js +++ b/addons/mail/static/src/attachments/attachment_viewer.js @@ -1,6 +1,7 @@ /* @odoo-module */ import { Component, useExternalListener, useRef, useState } from "@odoo/owl"; +import { useService } from "@web/core/utils/hooks"; /** * @typedef {Object} Props @@ -41,6 +42,7 @@ export class AttachmentViewer extends Component { scale: 1, angle: 0, }); + this.ui = useState(useService("ui")); } onImageLoaded() { diff --git a/addons/mail/static/src/attachments/attachment_viewer.xml b/addons/mail/static/src/attachments/attachment_viewer.xml index 1c42c9e5241..96d7f4cdcda 100644 --- a/addons/mail/static/src/attachments/attachment_viewer.xml +++ b/addons/mail/static/src/attachments/attachment_viewer.xml @@ -33,10 +33,10 @@ Viewer -