diff --git a/addons/mail/static/src/core/common/thread_service.js b/addons/mail/static/src/core/common/thread_service.js index 495f4e192e8..691759f648b 100644 --- a/addons/mail/static/src/core/common/thread_service.js +++ b/addons/mail/static/src/core/common/thread_service.js @@ -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 }); diff --git a/addons/mail/static/src/discuss/core/web/channel_selector.js b/addons/mail/static/src/discuss/core/web/channel_selector.js index bf06458ecf7..4fa87c0e0b9 100644 --- a/addons/mail/static/src/discuss/core/web/channel_selector.js +++ b/addons/mail/static/src/discuss/core/web/channel_selector.js @@ -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); }