[REF] mail: move createChannel 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 d8dde5d425
commit 1ad9fb496a
2 changed files with 12 additions and 11 deletions
@@ -447,16 +447,6 @@ export class ThreadService {
thread.pendingNewMessages = [];
}
async createChannel(name) {
const data = await this.orm.call("discuss.channel", "channel_create", [
name,
this.store.internalUserGroupId,
]);
const channel = this.createChannelThread(data);
this.sortChannels();
this.open(channel);
}
unpin(thread) {
if (this.store.discuss.threadLocalId === thread.localId) {
this.router.replaceState({ active_id: undefined });
@@ -20,7 +20,9 @@ export class ChannelSelector extends Component {
static template = "discuss.ChannelSelector";
setup() {
/** @type {import("@mail/core/common/store_service").Store} */
this.store = useStore();
/** @type {import("@mail/core/common/thread_service").ThreadService} */
this.threadService = useState(useService("mail.thread"));
this.personaService = useService("mail.persona");
/** @type {import("@mail/core/common/suggestion_service").SuggestionService} */
@@ -103,7 +105,16 @@ export class ChannelSelector extends Component {
onSelect(option) {
if (this.props.category.id === "channels") {
if (option.channelId === "__create__") {
this.threadService.createChannel(option.label);
this.env.services.orm
.call("discuss.channel", "channel_create", [
option.label,
this.store.internalUserGroupId,
])
.then((data) => {
const channel = this.threadService.createChannelThread(data);
this.threadService.sortChannels();
this.threadService.open(channel);
});
} else {
this.threadService.joinChannel(option.channelId, option.label);
}