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 @@ - + - + diff --git a/addons/mail/static/src/composer/composer.js b/addons/mail/static/src/composer/composer.js index 18806a3eb6e..bef4e8abda1 100644 --- a/addons/mail/static/src/composer/composer.js +++ b/addons/mail/static/src/composer/composer.js @@ -73,6 +73,7 @@ export class Composer extends Component { this.messageService = useState(useService("mail.message")); /** @type {import("@mail/core/thread_service").ThreadService} */ this.threadService = useService("mail.thread"); + this.ui = useState(useService("ui")); this.ref = useRef("textarea"); this.fakeTextarea = useRef("fakeTextarea"); this.state = useState({ diff --git a/addons/mail/static/src/composer/composer.xml b/addons/mail/static/src/composer/composer.xml index 371559c2133..58685e5b57d 100644 --- a/addons/mail/static/src/composer/composer.xml +++ b/addons/mail/static/src/composer/composer.xml @@ -62,8 +62,8 @@ - - + Send diff --git a/addons/mail/static/src/core/store_service.js b/addons/mail/static/src/core/store_service.js index f54ed42007b..311ed9c0229 100644 --- a/addons/mail/static/src/core/store_service.js +++ b/addons/mail/static/src/core/store_service.js @@ -14,7 +14,7 @@ export class Store { setup(env) { this.env = env; - this.isSmall = env.isSmall; + this.discuss.activeTab = this.env.services.ui.isSmall ? "mailbox" : "all"; } async updateBusSubscription() { @@ -149,10 +149,8 @@ export const storeService = { start(env, services) { const res = reactive(new Store(env, services)); onChange(res, "threads", () => res.updateBusSubscription()); - res.discuss.activeTab = res.isSmall ? "mailbox" : "all"; services.ui.bus.addEventListener("resize", () => { - res.isSmall = services.ui.isSmall; - if (!res.isSmall) { + if (!services.ui.isSmall) { res.discuss.activeTab = "all"; } else { res.discuss.activeTab = res.threads[res.discuss.threadLocalId]?.type ?? "all"; diff --git a/addons/mail/static/src/core/thread_service.js b/addons/mail/static/src/core/thread_service.js index 226d79dbbe1..5c9fd91f37d 100644 --- a/addons/mail/static/src/core/thread_service.js +++ b/addons/mail/static/src/core/thread_service.js @@ -39,6 +39,7 @@ export class ThreadService { this.rpc = services.rpc; this.notificationService = services.notification; this.router = services.router; + this.ui = services.ui; /** @type {import("@mail/core/persona_service").PersonaService} */ this.personaService = services["mail.persona"]; /** @type {import("@mail/core/message_service").MessageService} */ @@ -637,7 +638,7 @@ export class ThreadService { typeof thread.id === "string" ? `mail.box_${thread.id}` : `discuss.channel_${thread.id}`; - this.store.discuss.activeTab = !this.store.isSmall + this.store.discuss.activeTab = !this.ui.isSmall ? "all" : thread.model === "mail.box" ? "mailbox" @@ -1101,6 +1102,7 @@ export const threadService = { "router", "mail.persona", "mail.message", + "ui", ], start(env, services) { return new ThreadService(env, services); diff --git a/addons/mail/static/src/core_ui/message_reaction_menu.js b/addons/mail/static/src/core_ui/message_reaction_menu.js index a7712f7732a..5369fccbba3 100644 --- a/addons/mail/static/src/core_ui/message_reaction_menu.js +++ b/addons/mail/static/src/core_ui/message_reaction_menu.js @@ -24,6 +24,7 @@ export class MessageReactionMenu extends Component { this.threadService = useService("mail.thread"); this.root = useRef("root"); this.store = useStore(); + this.ui = useState(useService("ui")); this.messageService = useService("mail.message"); this.state = useState({ reaction: this.props.message.reactions[0], diff --git a/addons/mail/static/src/core_ui/message_reaction_menu.xml b/addons/mail/static/src/core_ui/message_reaction_menu.xml index 08fb94d6088..d44d7d095a8 100644 --- a/addons/mail/static/src/core_ui/message_reaction_menu.xml +++ b/addons/mail/static/src/core_ui/message_reaction_menu.xml @@ -13,7 +13,7 @@ - + diff --git a/addons/mail/static/src/core_ui/message_reactions.js b/addons/mail/static/src/core_ui/message_reactions.js index 153682a5438..15e4d7fa608 100644 --- a/addons/mail/static/src/core_ui/message_reactions.js +++ b/addons/mail/static/src/core_ui/message_reactions.js @@ -14,6 +14,7 @@ export class MessageReactions extends Component { this.user = useService("user"); this.messaging = useService("mail.messaging"); this.store = useStore(); + this.ui = useService("ui"); this.messageService = useState(useService("mail.message")); } @@ -72,7 +73,7 @@ export class MessageReactions extends Component { } onContextMenu(ev) { - if (this.store.isSmall) { + if (this.ui.isSmall) { ev.preventDefault(); this.props.openReactionMenu(); } diff --git a/addons/mail/static/src/core_ui/thread.js b/addons/mail/static/src/core_ui/thread.js index ce1fe63876d..f3c760e569b 100644 --- a/addons/mail/static/src/core_ui/thread.js +++ b/addons/mail/static/src/core_ui/thread.js @@ -52,6 +52,7 @@ export class Thread extends Component { this.state = useState({ isReplyingTo: false, showJumpPresent: false }); /** @type {import("@mail/core/thread_service").ThreadService} */ this.threadService = useState(useService("mail.thread")); + this.ui = useState(useService("ui")); if (!this.env.inChatter || !this.props.hasScrollAdjust) { useAutoScroll("messages", () => { if (this.env.messageHighlight?.highlightedMessageId) { diff --git a/addons/mail/static/src/core_ui/thread.xml b/addons/mail/static/src/core_ui/thread.xml index 221fcd5a2e7..7dc9d19581e 100644 --- a/addons/mail/static/src/core_ui/thread.xml +++ b/addons/mail/static/src/core_ui/thread.xml @@ -115,7 +115,7 @@ diff --git a/addons/mail/static/src/discuss/channel_invitation.js b/addons/mail/static/src/discuss/channel_invitation.js index 4f206b40849..8d3ff94b896 100644 --- a/addons/mail/static/src/discuss/channel_invitation.js +++ b/addons/mail/static/src/discuss/channel_invitation.js @@ -19,6 +19,7 @@ export class ChannelInvitation extends Component { this.notification = useService("notification"); this.threadService = useState(useService("mail.thread")); this.personaService = useService("mail.persona"); + this.ui = useService("ui"); this.inputRef = useRef("input"); this.searchStr = ""; this.state = useState({ @@ -107,7 +108,7 @@ export class ChannelInvitation extends Component { } ); } - if (this.env.isSmall) { + if (this.ui.isSmall) { this.props.chatState.activeMode = ""; } else { this.props.close(); diff --git a/addons/mail/static/src/discuss/web/chat_window_patch.xml b/addons/mail/static/src/discuss/web/chat_window_patch.xml index c668915e69e..a772a391aba 100644 --- a/addons/mail/static/src/discuss/web/chat_window_patch.xml +++ b/addons/mail/static/src/discuss/web/chat_window_patch.xml @@ -2,7 +2,7 @@ - + diff --git a/addons/mail/static/src/discuss_app/discuss.js b/addons/mail/static/src/discuss_app/discuss.js index 432ceb097d4..a966f5d9017 100644 --- a/addons/mail/static/src/discuss_app/discuss.js +++ b/addons/mail/static/src/discuss_app/discuss.js @@ -62,6 +62,7 @@ export class Discuss extends Component { this.state = useState({ activeMode: this.MODES.NONE }); this.orm = useService("orm"); this.effect = useService("effect"); + this.ui = useState(useService("ui")); this.prevInboxCounter = this.store.discuss.inbox.counter; useChildSubEnv({ inDiscussApp: true, diff --git a/addons/mail/static/src/discuss_app/discuss.xml b/addons/mail/static/src/discuss_app/discuss.xml index fa56e7481f2..86b0450e423 100644 --- a/addons/mail/static/src/discuss_app/discuss.xml +++ b/addons/mail/static/src/discuss_app/discuss.xml @@ -2,9 +2,9 @@ - - - + + + @@ -48,7 +48,7 @@ - + @@ -72,7 +72,7 @@ - + No conversation selected. diff --git a/addons/mail/static/src/discuss_app/pinned_messages_panel.js b/addons/mail/static/src/discuss_app/pinned_messages_panel.js index 5964bdf5dc5..c98c09ad547 100644 --- a/addons/mail/static/src/discuss_app/pinned_messages_panel.js +++ b/addons/mail/static/src/discuss_app/pinned_messages_panel.js @@ -1,6 +1,6 @@ /* @odoo-module */ -import { Component, onWillStart, onWillUpdateProps, useSubEnv } from "@odoo/owl"; +import { Component, onWillStart, onWillUpdateProps, useState, useSubEnv } from "@odoo/owl"; import { Message } from "@mail/core_ui/message"; import { MessageConfirmDialog } from "@mail/core_ui/message_confirm_dialog"; import { useService } from "@web/core/utils/hooks"; @@ -18,6 +18,8 @@ export class PinnedMessagesPanel extends Component { this.messageService = useService("mail.message"); this.store = useService("mail.store"); this.rpc = useService("rpc"); + this.ui = useState(useService("ui")); + onWillStart(() => { this.threadService.fetchPinnedMessages(this.props.thread); }); @@ -38,7 +40,7 @@ export class PinnedMessagesPanel extends Component { * @param {Message} message */ async onClickJump(message) { - if (this.env.isSmall) { + if (this.ui.isSmall) { this.env.pinMenu.close(); // Give the time to the pin menu to close before scrolling // to the message. diff --git a/addons/mail/static/src/discuss_app/pinned_messages_panel.xml b/addons/mail/static/src/discuss_app/pinned_messages_panel.xml index 9c08ff62843..ea82b166f6d 100644 --- a/addons/mail/static/src/discuss_app/pinned_messages_panel.xml +++ b/addons/mail/static/src/discuss_app/pinned_messages_panel.xml @@ -11,8 +11,8 @@ - Jump - Jump + diff --git a/addons/mail/static/src/views/activity/activity_controller.js b/addons/mail/static/src/views/activity/activity_controller.js index 9a3fe0d71c2..e2ed7e3fa16 100644 --- a/addons/mail/static/src/views/activity/activity_controller.js +++ b/addons/mail/static/src/views/activity/activity_controller.js @@ -2,7 +2,7 @@ import { useMessaging } from "@mail/core/messaging_hook"; -import { Component } from "@odoo/owl"; +import { Component, useState } from "@odoo/owl"; import { Layout } from "@web/search/layout"; import { standardViewProps } from "@web/views/standard_view_props"; @@ -41,6 +41,7 @@ export class ActivityController extends Component { this.action = useService("action"); this.messaging = useMessaging(); this.activity = useService("mail.activity"); + this.ui = useState(useService("ui")); } scheduleActivity() { diff --git a/addons/mail/static/src/views/activity/activity_controller.xml b/addons/mail/static/src/views/activity/activity_controller.xml index fb3f56e89da..69b5057427a 100644 --- a/addons/mail/static/src/views/activity/activity_controller.xml +++ b/addons/mail/static/src/views/activity/activity_controller.xml @@ -1,7 +1,7 @@ - + diff --git a/addons/mail/static/src/web/activity/activity_menu.js b/addons/mail/static/src/web/activity/activity_menu.js index 7652492c375..959d7bb4237 100644 --- a/addons/mail/static/src/web/activity/activity_menu.js +++ b/addons/mail/static/src/web/activity/activity_menu.js @@ -2,7 +2,7 @@ import { useMessaging, useStore } from "@mail/core/messaging_hook"; -import { Component } from "@odoo/owl"; +import { Component, useState } from "@odoo/owl"; import { Dropdown } from "@web/core/dropdown/dropdown"; import { registry } from "@web/core/registry"; @@ -18,6 +18,7 @@ export class ActivityMenu extends Component { this.store = useStore(); this.action = useService("action"); this.userId = useService("user").userId; + this.ui = useState(useService("ui")); this.fetchSystrayActivities(); } diff --git a/addons/mail/static/src/web/activity/activity_menu.xml b/addons/mail/static/src/web/activity/activity_menu.xml index ddda9dccaf2..91d8c85e1df 100644 --- a/addons/mail/static/src/web/activity/activity_menu.xml +++ b/addons/mail/static/src/web/activity/activity_menu.xml @@ -2,13 +2,13 @@ - + - + Congratulations, you're done with your activities. diff --git a/addons/mail/static/src/web/chat_window/chat_window.js b/addons/mail/static/src/web/chat_window/chat_window.js index d09826385da..34af53d7caf 100644 --- a/addons/mail/static/src/web/chat_window/chat_window.js +++ b/addons/mail/static/src/web/chat_window/chat_window.js @@ -57,6 +57,7 @@ export class ChatWindow extends Component { activeMode: "", }); this.action = useService("action"); + this.ui = useState(useService("ui")); this.contentRef = useRef("content"); useChildSubEnv({ inChatWindow: true, @@ -77,10 +78,10 @@ export class ChatWindow extends Component { } get style() { - const maxHeight = !this.store.isSmall ? "max-height: 95vh;" : ""; + const maxHeight = !this.ui.isSmall ? "max-height: 95vh;" : ""; const textDirection = localization.direction; const offsetFrom = textDirection === "rtl" ? "left" : "right"; - const visibleOffset = this.store.isSmall ? 0 : this.props.right; + const visibleOffset = this.ui.isSmall ? 0 : this.props.right; const oppositeFrom = offsetFrom === "right" ? "left" : "right"; return `${offsetFrom}: ${visibleOffset}px; ${oppositeFrom}: auto; ${maxHeight}`; } @@ -112,7 +113,7 @@ export class ChatWindow extends Component { } toggleFold() { - if (this.store.isSmall) { + if (this.ui.isSmall) { return; } if (this.props.chatWindow.hidden) { diff --git a/addons/mail/static/src/web/chat_window/chat_window.xml b/addons/mail/static/src/web/chat_window/chat_window.xml index b970743ed83..d83230df505 100644 --- a/addons/mail/static/src/web/chat_window/chat_window.xml +++ b/addons/mail/static/src/web/chat_window/chat_window.xml @@ -5,19 +5,19 @@ - - + + - + @@ -32,14 +32,14 @@ () - + - + diff --git a/addons/mail/static/src/web/chat_window/chat_window_container.js b/addons/mail/static/src/web/chat_window/chat_window_container.js index a91b23b4605..3223daf6c61 100644 --- a/addons/mail/static/src/web/chat_window/chat_window_container.js +++ b/addons/mail/static/src/web/chat_window/chat_window_container.js @@ -45,6 +45,7 @@ export class ChatWindowContainer extends Component { this.messaging = useMessaging(); this.store = useStore(); this.chatWindowService = useState(useService("mail.chat_window")); + this.ui = useState(useService("ui")); this.hiddenMenuRef = useRef("hiddenMenu"); useEffect( () => this.setHiddenMenuOffset(), diff --git a/addons/mail/static/src/web/chat_window/chat_window_container.xml b/addons/mail/static/src/web/chat_window/chat_window_container.xml index e4950d0588a..d5e9e9a9699 100644 --- a/addons/mail/static/src/web/chat_window/chat_window_container.xml +++ b/addons/mail/static/src/web/chat_window/chat_window_container.xml @@ -2,8 +2,8 @@ - - + + diff --git a/addons/mail/static/src/web/chat_window/chat_window_service.js b/addons/mail/static/src/web/chat_window/chat_window_service.js index 030cbb05b14..41debbd14dd 100644 --- a/addons/mail/static/src/web/chat_window/chat_window_service.js +++ b/addons/mail/static/src/web/chat_window/chat_window_service.js @@ -16,6 +16,7 @@ export class ChatWindowService { /** @type {import("@mail/core/store_service").Store} */ this.store = services["mail.store"]; this.orm = services.orm; + this.ui = services.ui; } openNewMessage() { @@ -42,12 +43,12 @@ export class ChatWindowService { } get maxVisible() { - const startGap = this.store.isSmall + const startGap = this.ui.isSmall ? 0 : this.hidden.length > 0 ? CHAT_WINDOW_END_GAP_WIDTH + CHAT_WINDOW_HIDDEN_WIDTH : CHAT_WINDOW_END_GAP_WIDTH; - const endGap = this.store.isSmall ? 0 : CHAT_WINDOW_END_GAP_WIDTH; + const endGap = this.ui.isSmall ? 0 : CHAT_WINDOW_END_GAP_WIDTH; const available = browser.innerWidth - startGap - endGap; const maxAmountWithoutHidden = Math.floor( available / (CHAT_WINDOW_WIDTH + CHAT_WINDOW_INBETWEEN_WIDTH) @@ -56,7 +57,7 @@ export class ChatWindowService { } notifyState(chatWindow) { - if (this.env.isSmall) { + if (this.ui.isSmall) { return; } if (chatWindow.thread?.model === "discuss.channel") { @@ -142,7 +143,7 @@ export class ChatWindowService { } async close(chatWindow, { escape = false } = {}) { - if (this.store.isSmall && !this.store.discuss.isActive) { + if (this.ui.isSmall && !this.store.discuss.isActive) { // If we are in mobile and discuss is not open, it means the // chat window was opened from the messaging menu. In that // case it should be re-opened to simulate it was always @@ -171,7 +172,7 @@ export class ChatWindowService { } export const chatWindowService = { - dependencies: ["mail.store", "orm"], + dependencies: ["mail.store", "orm", "ui"], start(env, services) { return new ChatWindowService(env, services); }, diff --git a/addons/mail/static/src/web/discuss_app/discuss_patch.xml b/addons/mail/static/src/web/discuss_app/discuss_patch.xml index 4764770fbf5..8fcad41f5fe 100644 --- a/addons/mail/static/src/web/discuss_app/discuss_patch.xml +++ b/addons/mail/static/src/web/discuss_app/discuss_patch.xml @@ -2,10 +2,10 @@ - + - + diff --git a/addons/mail/static/src/web/messaging_menu/messaging_menu.js b/addons/mail/static/src/web/messaging_menu/messaging_menu.js index 89288e1b04b..d6eaceb98e6 100644 --- a/addons/mail/static/src/web/messaging_menu/messaging_menu.js +++ b/addons/mail/static/src/web/messaging_menu/messaging_menu.js @@ -31,6 +31,7 @@ export class MessagingMenu extends Component { /** @type {import("@mail/core/thread_service").ThreadService} */ this.threadService = useState(useService("mail.thread")); this.action = useService("action"); + this.ui = useState(useService("ui")); this.state = useState({ addingChat: false, addingChannel: false, @@ -201,7 +202,7 @@ export class MessagingMenu extends Component { } onClickNewMessage() { - if (this.store.isSmall && this.env.inDiscussApp) { + if (this.ui.isSmall && this.env.inDiscussApp) { this.state.addingChat = true; } else { this.chatWindowService.openNewMessage(); diff --git a/addons/mail/static/src/web/messaging_menu/messaging_menu.xml b/addons/mail/static/src/web/messaging_menu/messaging_menu.xml index e228c696f24..ecce993c301 100644 --- a/addons/mail/static/src/web/messaging_menu/messaging_menu.xml +++ b/addons/mail/static/src/web/messaging_menu/messaging_menu.xml @@ -2,9 +2,9 @@ - + - + @@ -16,17 +16,17 @@ - - + - + All Chats Channels - + @@ -103,7 +103,7 @@ - + (env.services["mail.store"].isSmall = true)); + await afterNextRender(() => { + patchUiSize({ size: SIZES.SM }); + window.dispatchEvent(new UIEvent("resize")); + }); assert.containsNone($, ".o-mail-ChatWindowHiddenToggler"); } ); diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js index 1a70b02a09e..3ab87add006 100644 --- a/addons/mail/static/tests/helpers/test_utils.js +++ b/addons/mail/static/tests/helpers/test_utils.js @@ -418,7 +418,7 @@ async function start(param0 = {}) { await afterNextRender(async () => { webClient = await getWebClientReady({ ...param0, messagingBus }); }); - if (webClient.env.isSmall) { + if (webClient.env.services.ui.isSmall) { target.style.width = "100%"; } const openView = async (action, options) => {