This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/plugins/chat/assets/javascripts/discourse/routes/chat-channel.js
2023-02-13 11:03:20 +10:00

27 lines
715 B
JavaScript

import DiscourseRoute from "discourse/routes/discourse";
import withChatChannel from "./chat-channel-decorator";
import { inject as service } from "@ember/service";
import { action } from "@ember/object";
@withChatChannel
export default class ChatChannelRoute extends DiscourseRoute {
@service chatThreadsManager;
@service chatStateManager;
@action
willTransition(transition) {
this.chat.activeThread = null;
this.chatStateManager.closeSidePanel();
if (!transition?.to?.name?.startsWith("chat.")) {
this.chatStateManager.storeChatURL();
this.chat.activeChannel = null;
this.chat.updatePresence();
}
}
beforeModel() {
this.chatThreadsManager.resetCache();
}
}