diff --git a/addons/hr_holidays/static/src/components/thread_icon/thread_icon.xml b/addons/hr_holidays/static/src/components/thread_icon/thread_icon.xml index 6d7b444ed1f..17888a19735 100644 --- a/addons/hr_holidays/static/src/components/thread_icon/thread_icon.xml +++ b/addons/hr_holidays/static/src/components/thread_icon/thread_icon.xml @@ -2,13 +2,13 @@ - +
- +
- +
diff --git a/addons/im_livechat/static/src/components/thread_icon/thread_icon.xml b/addons/im_livechat/static/src/components/thread_icon/thread_icon.xml index e22c2fca64f..86648d84274 100644 --- a/addons/im_livechat/static/src/components/thread_icon/thread_icon.xml +++ b/addons/im_livechat/static/src/components/thread_icon/thread_icon.xml @@ -2,12 +2,12 @@ - - + + diff --git a/addons/im_livechat/static/src/models/discuss_sidebar_category_item.js b/addons/im_livechat/static/src/models/discuss_sidebar_category_item.js index 1716a331633..811adde5422 100644 --- a/addons/im_livechat/static/src/models/discuss_sidebar_category_item.js +++ b/addons/im_livechat/static/src/models/discuss_sidebar_category_item.js @@ -32,14 +32,6 @@ registerPatch({ return this._super(); }, }, - hasThreadIcon: { - compute() { - if (this.channel.channel_type === 'livechat') { - return clear(); - } - return this._super(); - }, - }, hasUnpinCommand: { compute() { if (this.channel.channel_type === 'livechat') { @@ -48,5 +40,13 @@ registerPatch({ return this._super(); }, }, + threadIconView: { + compute() { + if (this.channel.channel_type === 'livechat') { + return clear(); + } + return this._super(); + }, + }, }, }); diff --git a/addons/mail/static/src/components/chat_window_header/chat_window_header.xml b/addons/mail/static/src/components/chat_window_header/chat_window_header.xml index 812b8ddedbe..7b7ed8a178c 100644 --- a/addons/mail/static/src/components/chat_window_header/chat_window_header.xml +++ b/addons/mail/static/src/components/chat_window_header/chat_window_header.xml @@ -9,10 +9,10 @@
- +
diff --git a/addons/mail/static/src/components/discuss_sidebar_category_item/discuss_sidebar_category_item.xml b/addons/mail/static/src/components/discuss_sidebar_category_item/discuss_sidebar_category_item.xml index dc34baeeabe..3a42942876b 100644 --- a/addons/mail/static/src/components/discuss_sidebar_category_item/discuss_sidebar_category_item.xml +++ b/addons/mail/static/src/components/discuss_sidebar_category_item/discuss_sidebar_category_item.xml @@ -14,8 +14,8 @@
Thread Image - - + +
diff --git a/addons/mail/static/src/components/discuss_sidebar_mailbox/discuss_sidebar_mailbox.xml b/addons/mail/static/src/components/discuss_sidebar_mailbox/discuss_sidebar_mailbox.xml index 7e060b1f1b6..d6a4c02c44d 100644 --- a/addons/mail/static/src/components/discuss_sidebar_mailbox/discuss_sidebar_mailbox.xml +++ b/addons/mail/static/src/components/discuss_sidebar_mailbox/discuss_sidebar_mailbox.xml @@ -9,7 +9,7 @@ }" t-attf-class="{{ className }}" t-on-click="discussSidebarMailboxView.mailbox.thread.onClick" t-att-data-mailbox-local-id="discussSidebarMailboxView.mailbox.localId" t-att-data-mailbox-name="discussSidebarMailboxView.mailbox.name" t-ref="root" > - +
diff --git a/addons/mail/static/src/components/thread_icon/thread_icon.js b/addons/mail/static/src/components/thread_icon/thread_icon.js index 6fb1c5801ea..98b01a786a8 100644 --- a/addons/mail/static/src/components/thread_icon/thread_icon.js +++ b/addons/mail/static/src/components/thread_icon/thread_icon.js @@ -7,16 +7,16 @@ const { Component } = owl; export class ThreadIcon extends Component { /** - * @returns {Thread} + * @returns {ThreadIconView} */ - get thread() { - return this.props.thread; + get threadIconView() { + return this.props.record; } } Object.assign(ThreadIcon, { - props: { thread: Object }, + props: { record: Object }, template: 'mail.ThreadIcon', }); diff --git a/addons/mail/static/src/components/thread_icon/thread_icon.xml b/addons/mail/static/src/components/thread_icon/thread_icon.xml index b67fc0296cb..9783ed4d597 100644 --- a/addons/mail/static/src/components/thread_icon/thread_icon.xml +++ b/addons/mail/static/src/components/thread_icon/thread_icon.xml @@ -2,51 +2,51 @@ - +
- - -
+ + +
- +
- - + + - +
- +
- +
- +
- +
- - + +
- +
- +
diff --git a/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml b/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml index b0cec2c32e3..bd9cb2577c3 100644 --- a/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml +++ b/addons/mail/static/src/components/thread_view_topbar/thread_view_topbar.xml @@ -4,8 +4,8 @@
- - + +
diff --git a/addons/mail/static/src/models/chat_window_header_view.js b/addons/mail/static/src/models/chat_window_header_view.js index fd7081caff3..d88702e3e3a 100644 --- a/addons/mail/static/src/models/chat_window_header_view.js +++ b/addons/mail/static/src/models/chat_window_header_view.js @@ -2,6 +2,7 @@ import { registerModel } from '@mail/model/model_core'; import { one } from '@mail/model/model_field'; +import { clear } from '@mail/model/model_field_command'; import { isEventHandled } from '@mail/utils/utils'; registerModel({ @@ -33,5 +34,14 @@ registerModel({ identifying: true, inverse: 'chatWindowHeaderView', }), + threadIconView: one('ThreadIconView', { + compute() { + if (this.chatWindowOwner.thread && this.chatWindowOwner.thread.channel) { + return {}; + } + return clear(); + }, + inverse: 'chatWindowHeaderViewOwner', + }) }, }); diff --git a/addons/mail/static/src/models/discuss_sidebar_category_item.js b/addons/mail/static/src/models/discuss_sidebar_category_item.js index 871bfe353bc..fa6e722168f 100644 --- a/addons/mail/static/src/models/discuss_sidebar_category_item.js +++ b/addons/mail/static/src/models/discuss_sidebar_category_item.js @@ -188,24 +188,6 @@ registerModel({ return this.channel.channel_type === 'channel'; }, }), - /** - * Boolean determines whether ThreadIcon will be displayed in UI. - */ - hasThreadIcon: attr({ - compute() { - if (!this.thread) { - return clear(); - } - switch (this.channel.channel_type) { - case 'channel': - return !Boolean(this.thread.authorizedGroupFullName); - case 'chat': - return true; - case 'group': - return false; - } - }, - }), /** * Boolean determines whether the item has a "unpin" command. */ @@ -236,5 +218,21 @@ registerModel({ thread: one('Thread', { related: 'channel.thread' }), + threadIconView: one('ThreadIconView', { + compute() { + if (!this.thread) { + return clear(); + } + switch (this.channel.channel_type) { + case 'channel': + return this.thread.authorizedGroupFullName ? clear() : {}; + case 'chat': + return {}; + case 'group': + return clear(); + } + }, + inverse: 'discussSidebarCategoryItemOwner', + }), }, }); diff --git a/addons/mail/static/src/models/discuss_sidebar_mailbox_view.js b/addons/mail/static/src/models/discuss_sidebar_mailbox_view.js index 9bddef1b226..df01a38c543 100644 --- a/addons/mail/static/src/models/discuss_sidebar_mailbox_view.js +++ b/addons/mail/static/src/models/discuss_sidebar_mailbox_view.js @@ -35,5 +35,9 @@ registerModel({ }, required: true, }), + threadIconView: one('ThreadIconView', { + default: {}, + inverse: 'discussSidebarMailboxViewOwner', + }), }, }); diff --git a/addons/mail/static/src/models/messaging_notification_handler.js b/addons/mail/static/src/models/messaging_notification_handler.js index b1ee7197e36..28eed0a1ca1 100644 --- a/addons/mail/static/src/models/messaging_notification_handler.js +++ b/addons/mail/static/src/models/messaging_notification_handler.js @@ -7,7 +7,6 @@ import { htmlToTextContentInline } from '@mail/js/utils'; import { escape, sprintf } from '@web/core/utils/strings'; import { str_to_datetime } from 'web.time'; import { Markup } from 'web.utils'; -import { renderToString } from "@web/core/utils/render"; const PREVIEW_MSG_MAX_SIZE = 350; // optimal for native English speakers @@ -651,19 +650,12 @@ registerModel({ notificationTitle = this.env._t("New message"); } else { if (channel.channel_type === 'channel') { - // hack: notification template does not support OWL components, - // so we simply use their template to make HTML as if it comes - // from component - const channelIcon = renderToString('mail.ThreadIcon', { - env: this.env, - thread: channel.thread, - }); - const channelName = channel.thread.displayName; - const channelNameWithIcon = channelIcon + channelName; notificationTitle = sprintf( - this.env._t("%s from %s"), - author.nameOrDisplayName, - channelNameWithIcon + this.env._t("%(author name)s from %(channel name)s"), + { + 'author name': author.nameOrDisplayName, + 'channel name': channel.displayName, + } ); } else { notificationTitle = author.nameOrDisplayName; diff --git a/addons/mail/static/src/models/thread_icon_view.js b/addons/mail/static/src/models/thread_icon_view.js new file mode 100644 index 00000000000..845abf71ebe --- /dev/null +++ b/addons/mail/static/src/models/thread_icon_view.js @@ -0,0 +1,44 @@ +/** @odoo-module **/ + +import { registerModel } from '@mail/model/model_core'; +import { one } from '@mail/model/model_field'; + +registerModel({ + name: 'ThreadIconView', + identifyingMode: 'xor', + fields: { + chatWindowHeaderViewOwner: one('ChatWindowHeaderView', { + identifying: true, + inverse: 'threadIconView', + }), + discussSidebarCategoryItemOwner: one('DiscussSidebarCategoryItem', { + identifying: true, + inverse: 'threadIconView', + }), + discussSidebarMailboxViewOwner: one('DiscussSidebarMailboxView', { + identifying: true, + inverse: 'threadIconView', + }), + thread: one('Thread', { + compute() { + if (this.chatWindowHeaderViewOwner) { + return this.chatWindowHeaderViewOwner.chatWindowOwner.thread; + } + if (this.discussSidebarCategoryItemOwner) { + return this.discussSidebarCategoryItemOwner.thread; + } + if (this.discussSidebarMailboxViewOwner) { + return this.discussSidebarMailboxViewOwner.mailbox.thread; + } + if (this.threadViewTopbarOwner) { + return this.threadViewTopbarOwner.thread + } + }, + required: true, + }), + threadViewTopbarOwner: one('ThreadViewTopbar', { + identifying: true, + inverse: 'threadIconView', + }), + }, +}); diff --git a/addons/mail/static/src/models/thread_view_topbar.js b/addons/mail/static/src/models/thread_view_topbar.js index 924b7490ff2..89166dd61d4 100644 --- a/addons/mail/static/src/models/thread_view_topbar.js +++ b/addons/mail/static/src/models/thread_view_topbar.js @@ -688,6 +688,15 @@ registerModel({ * Useful to focus it, or to know when a click is done outside of it. */ threadDescriptionInputRef: attr(), + threadIconView: one('ThreadIconView', { + compute() { + if (this.thread) { + return {}; + } + return clear(); + }, + inverse: 'threadViewTopbarOwner', + }), /** * States the thread view managing this top bar. */