[REF] mail, im_livechat: init channel and sidebar in new services

Part of task-3265211

Part-of: odoo/odoo#128799
This commit is contained in:
Sébastien Theys
2023-07-18 19:28:07 +02:00
parent 64b1d9d4f2
commit d8dde5d425
4 changed files with 12 additions and 9 deletions
@@ -16,6 +16,7 @@ patch(Messaging.prototype, "im_livechat", {
this.store.isMessagingReady = true;
this.isReady.resolve({
channels: [],
current_user_settings: {},
});
},
});
@@ -93,16 +93,10 @@ export class Messaging {
...data.odoobot,
type: "partner",
});
for (const channelData of data.channels) {
this.threadService.createChannelThread(channelData);
}
this.threadService.sortChannels();
const settings = data.current_user_settings;
this.userSettingsService.updateFromCommands(settings);
this.userSettingsService.id = settings.id;
this.store.companyName = data.companyName;
this.store.discuss.channels.isOpen = settings.is_discuss_sidebar_category_channel_open;
this.store.discuss.chats.isOpen = settings.is_discuss_sidebar_category_chat_open;
this.store.discuss.inbox.counter = data.needaction_inbox_counter;
this.store.internalUserGroupId = data.internalUserGroupId;
this.store.discuss.starred.counter = data.starred_counter;
@@ -31,7 +31,11 @@ export class DiscussCoreCommon {
}
setup() {
this.messagingService.isReady.then(() => {
this.messagingService.isReady.then((data) => {
for (const channelData of data.channels) {
this.threadService.createChannelThread(channelData);
}
this.threadService.sortChannels();
this.busService.subscribe("discuss.channel/joined", (payload) => {
const { channel, invited_by_user_id: invitedByUserId } = payload;
const thread = this.threadService.insert({
@@ -25,8 +25,8 @@ export class DiscussCoreWeb {
}
setup() {
this.messagingService.isReady.then(({ channels }) => {
for (const channelData of channels) {
this.messagingService.isReady.then((data) => {
for (const channelData of data.channels) {
const thread = this.threadService.createChannelThread(channelData);
if (
channelData.is_minimized &&
@@ -40,6 +40,10 @@ export class DiscussCoreWeb {
});
}
}
this.store.discuss.channels.isOpen =
data.current_user_settings.is_discuss_sidebar_category_channel_open;
this.store.discuss.chats.isOpen =
data.current_user_settings.is_discuss_sidebar_category_chat_open;
});
this.env.bus.addEventListener(
"discuss.channel/new_message",