diff --git a/addons/im_livechat/static/src/components/composer/composer.xml b/addons/im_livechat/static/src/components/composer/composer.xml
index d513d12eda7..b012c1a6165 100644
--- a/addons/im_livechat/static/src/components/composer/composer.xml
+++ b/addons/im_livechat/static/src/components/composer/composer.xml
@@ -3,7 +3,7 @@
- $0
+ $0
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 a4a6f1570dc..e22c2fca64f 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,7 +2,7 @@
-
+
0) {
- return this.channel.correspondent.avatarUrl;
+ if (this.channel && this.channel.channel_type === 'livechat') {
+ if (this.thread.correspondent && this.thread.correspondent.id > 0) {
+ return this.thread.correspondent.avatarUrl;
}
}
return this._super();
@@ -20,9 +21,8 @@ patchRecordMethods('DiscussSidebarCategoryItem', {
* @override
*/
_computeCategoryCounterContribution() {
- switch (this.channel.channel_type) {
- case 'livechat':
- return this.channel.localMessageUnreadCounter > 0 ? 1 : 0;
+ if (this.channel && this.channel.channel_type === 'livechat') {
+ return this.thread.localMessageUnreadCounter > 0 ? 1 : 0;
}
return this._super();
},
@@ -30,8 +30,8 @@ patchRecordMethods('DiscussSidebarCategoryItem', {
* @override
*/
_computeCounter() {
- if (this.channelType === 'livechat') {
- return this.channel.localMessageUnreadCounter;
+ if (this.channel && this.channel.channel_type === 'livechat') {
+ return this.thread.localMessageUnreadCounter;
}
return this._super();
},
@@ -39,8 +39,8 @@ patchRecordMethods('DiscussSidebarCategoryItem', {
* @override
*/
_computeHasUnpinCommand() {
- if (this.channelType === 'livechat') {
- return !this.channel.localMessageUnreadCounter;
+ if (this.channel && this.channel.channel_type === 'livechat') {
+ return !this.thread.localMessageUnreadCounter;
}
return this._super();
},
@@ -48,8 +48,8 @@ patchRecordMethods('DiscussSidebarCategoryItem', {
* @override
*/
_computeHasThreadIcon() {
- if (this.channelType === 'livechat') {
- return false;
+ if (this.channel && this.channel.channel_type === 'livechat') {
+ return clear();
}
return this._super();
},
diff --git a/addons/im_livechat/static/src/models/message.js b/addons/im_livechat/static/src/models/message.js
index d9380dd4c80..d9e8ef40043 100644
--- a/addons/im_livechat/static/src/models/message.js
+++ b/addons/im_livechat/static/src/models/message.js
@@ -29,7 +29,7 @@ patchRecordMethods('Message', {
* @override
*/
_computeHasReactionIcon() {
- if (this.originThread && this.originThread.channel_type === 'livechat') {
+ if (this.originThread && this.originThread.channel && this.originThread.channel.channel_type === 'livechat') {
return false;
}
return this._super();
diff --git a/addons/im_livechat/static/src/models/message_action_list.js b/addons/im_livechat/static/src/models/message_action_list.js
index b73ad2654bc..a07261ba4af 100644
--- a/addons/im_livechat/static/src/models/message_action_list.js
+++ b/addons/im_livechat/static/src/models/message_action_list.js
@@ -12,7 +12,8 @@ patchRecordMethods('MessageActionList', {
if (
this.message &&
this.message.originThread &&
- this.message.originThread.channel_type === 'livechat'
+ this.message.originThread.channel &&
+ this.message.originThread.channel.channel_type === 'livechat'
) {
return false;
}
diff --git a/addons/im_livechat/static/src/models/notification_list_view.js b/addons/im_livechat/static/src/models/notification_list_view.js
index a00d6164097..887a7aea3a6 100644
--- a/addons/im_livechat/static/src/models/notification_list_view.js
+++ b/addons/im_livechat/static/src/models/notification_list_view.js
@@ -11,9 +11,9 @@ patchRecordMethods('NotificationListView', {
_computeFilteredThreads() {
if (this.filter === 'livechat') {
return replace(this.messaging.models['Thread'].all(thread =>
- thread.channel_type === 'livechat' &&
- thread.isPinned &&
- thread.model === 'mail.channel'
+ thread.channel &&
+ thread.channel.channel_type === 'livechat' &&
+ thread.isPinned
));
}
return this._super();
diff --git a/addons/im_livechat/static/src/models/thread.js b/addons/im_livechat/static/src/models/thread.js
index 6ea7d386738..671c2b167dd 100644
--- a/addons/im_livechat/static/src/models/thread.js
+++ b/addons/im_livechat/static/src/models/thread.js
@@ -22,7 +22,7 @@ addRecordMethods('Thread', {
* @returns {FieldCommand}
*/
_computeMessagingAsPinnedLivechat() {
- if (!this.messaging || this.channel_type !== 'livechat' || !this.isPinned) {
+ if (!this.messaging || !this.channel || this.channel.channel_type !== 'livechat' || !this.isPinned) {
return clear();
}
return replace(this.messaging);
@@ -81,7 +81,7 @@ patchRecordMethods('Thread', {
* @override
*/
getMemberName(partner) {
- if (this.channel_type === 'livechat' && partner.livechat_username) {
+ if (this.channel && this.channel.channel_type === 'livechat' && partner.livechat_username) {
return partner.livechat_username;
}
return this._super(partner);
@@ -90,7 +90,7 @@ patchRecordMethods('Thread', {
* @override
*/
_computeCorrespondent() {
- if (this.channel_type === 'livechat') {
+ if (this.channel && this.channel.channel_type === 'livechat') {
// livechat correspondent never change: always the public member.
return;
}
@@ -100,7 +100,7 @@ patchRecordMethods('Thread', {
* @override
*/
_computeDisplayName() {
- if (this.channel_type === 'livechat' && this.correspondent) {
+ if (this.channel && this.channel.channel_type === 'livechat' && this.correspondent) {
if (this.correspondent.country) {
return `${this.correspondent.nameOrDisplayName} (${this.correspondent.country.name})`;
}
@@ -112,7 +112,7 @@ patchRecordMethods('Thread', {
* @override
*/
_computeHasInviteFeature() {
- if (this.channel_type === 'livechat') {
+ if (this.channel && this.channel.channel_type === 'livechat') {
return true;
}
return this._super();
@@ -121,7 +121,7 @@ patchRecordMethods('Thread', {
* @override
*/
_computeHasMemberListFeature() {
- if (this.channel_type === 'livechat') {
+ if (this.channel && this.channel.channel_type === 'livechat') {
return true;
}
return this._super();
@@ -130,15 +130,17 @@ patchRecordMethods('Thread', {
* @override
*/
_computeIsChatChannel() {
- return this.channel_type === 'livechat' || this._super();
+ if (this.channel && this.channel.channel_type === 'livechat') {
+ return true;
+ }
+ return this._super();
},
/**
* @override
*/
_getDiscussSidebarCategory() {
- switch (this.channel_type) {
- case 'livechat':
- return this.messaging.discuss.categoryLivechat;
+ if (this.channel.channel_type === 'livechat') {
+ return this.messaging.discuss.categoryLivechat;
}
return this._super();
}
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index a311c6f2a72..457c792f08b 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -765,6 +765,10 @@ class Channel(models.Model):
if self.env.user and self.env.user.partner_id and member.partner_id == self.env.user.partner_id:
member_of_current_user_by_channel[member.channel_id] = member
for channel in self:
+ channel_data = {
+ 'channel_type': channel.channel_type,
+ 'id': channel.id,
+ }
info = {
'avatarCacheKey': channel._get_avatar_cache_key(),
'id': channel.id,
@@ -774,7 +778,6 @@ class Channel(models.Model):
'uuid': channel.uuid,
'state': 'open',
'is_minimized': False,
- 'channel_type': channel.channel_type,
'public': channel.public,
'group_based_subscription': bool(channel.group_ids),
'create_uid': channel.create_uid.id,
@@ -820,6 +823,8 @@ class Channel(models.Model):
'rtcSessions': [('insert', rtc_sessions_by_channel.get(channel, []))],
})
+ info['channel'] = [('insert-and-replace', channel_data)]
+
channel_infos.append(info)
return channel_infos
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 a7119429354..3105a352208 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
@@ -8,22 +8,22 @@
'bg-100': !categoryItem.isActive,
'o-active bg-200': categoryItem.isActive,
'o-unread': categoryItem.isUnread,
- }" t-attf-class="{{ className }}" t-on-click="categoryItem.onClick" t-att-data-thread-local-id="categoryItem.channel.localId" t-att-data-thread-name="categoryItem.channel.displayName"
+ }" t-attf-class="{{ className }}" t-on-click="categoryItem.onClick" t-att-data-thread-local-id="categoryItem.thread.localId" t-att-data-thread-name="categoryItem.thread.displayName"
t-ref="root"
>
-