[REF] mail: move createGroupChat to discuss folder

Part of task-3265211

Part-of: odoo/odoo#128799
This commit is contained in:
Sébastien Theys
2023-07-18 19:28:08 +02:00
parent 397d1d1a53
commit 744cf53146
3 changed files with 17 additions and 13 deletions
@@ -662,17 +662,6 @@ export class ThreadService {
}
}
async createGroupChat({ default_display_mode, partners_to }) {
const data = await this.orm.call("discuss.channel", "create_group", [], {
default_display_mode,
partners_to,
});
const channel = this.createChannelThread(data);
this.sortChannels();
this.open(channel);
return channel;
}
remove(thread) {
removeFromArray(this.store.discuss.chats.threads, thread.localId);
removeFromArray(this.store.discuss.channels.threads, thread.localId);
@@ -2,6 +2,7 @@
import { Sidebar } from "@mail/core/web/sidebar";
import { useRtc } from "@mail/discuss/call/common/rtc_hook";
import { useDiscussCoreCommon } from "@mail/discuss/core/common/discuss_core_common_service";
import { patch } from "@web/core/utils/patch";
@@ -10,10 +11,11 @@ Sidebar.props = [...Sidebar.props, "onStartMeeting?"];
patch(Sidebar.prototype, "discuss/call/web", {
setup() {
this._super(...arguments);
this.discussCoreCommonService = useDiscussCoreCommon();
this.rtc = useRtc();
},
async onClickStartMeeting() {
const thread = await this.threadService.createGroupChat({
const thread = await this.discussCoreCommonService.createGroupChat({
default_display_mode: "video_full_screen",
partners_to: [this.store.self.id],
});
@@ -15,6 +15,7 @@ export class DiscussCoreCommon {
Object.assign(this, {
busService: services.bus_service,
env,
orm: services.orm,
presence: services.presence,
rpc: services.rpc,
});
@@ -153,6 +154,17 @@ export class DiscussCoreCommon {
});
}
async createGroupChat({ default_display_mode, partners_to }) {
const data = await this.orm.call("discuss.channel", "create_group", [], {
default_display_mode,
partners_to,
});
const channel = this.threadService.createChannelThread(data);
this.threadService.sortChannels();
this.threadService.open(channel);
return channel;
}
/**
* @param {[number]} partnerIds
* @param {boolean} inChatWindow
@@ -169,7 +181,7 @@ export class DiscussCoreCommon {
const chat = await this.threadService.joinChat(correspondentId);
this.threadService.open(chat, inChatWindow);
} else {
await this.threadService.createGroupChat({ partners_to });
await this.createGroupChat({ partners_to });
}
}
@@ -264,6 +276,7 @@ export const discussCoreCommon = {
"mail.store",
"mail.thread",
"notification",
"orm",
"presence",
"rpc",
],