mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 02:29:29 +08:00

The following case was bugged:
- visit a thread in full page chat
- click channel title
- click back button in channel navbar
- 💥 you would have a channel with limited width as if there was
still the thread showing next to it, but it was empty
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
import { action } from "@ember/object";
|
|
import { service } from "@ember/service";
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
|
|
export default class ChatChannelThread extends DiscourseRoute {
|
|
@service router;
|
|
@service chatStateManager;
|
|
@service chat;
|
|
|
|
redirectToChannel(channel, transition) {
|
|
transition.abort();
|
|
this.chatStateManager.closeSidePanel();
|
|
this.router.transitionTo("chat.channel", ...channel.routeModels);
|
|
}
|
|
|
|
model(params, transition) {
|
|
const channel = this.modelFor("chat.channel");
|
|
return channel.threadsManager
|
|
.find(channel.id, params.threadId)
|
|
.catch(() => {
|
|
this.redirectToChannel(channel, transition);
|
|
return;
|
|
});
|
|
}
|
|
|
|
afterModel(thread, transition) {
|
|
const channel = this.modelFor("chat.channel");
|
|
|
|
if (!channel.threadingEnabled && !thread.force) {
|
|
this.redirectToChannel(channel, transition);
|
|
return;
|
|
}
|
|
|
|
channel.activeThread = thread;
|
|
}
|
|
|
|
@action
|
|
activate() {
|
|
this.chat.activeMessage = null;
|
|
this.chatStateManager.openSidePanel();
|
|
}
|
|
|
|
@action
|
|
deactivate() {
|
|
this.chatStateManager.closeSidePanel();
|
|
}
|
|
|
|
beforeModel() {
|
|
const { messageId } = this.paramsFor(this.routeName + ".near-message");
|
|
if (
|
|
!messageId &&
|
|
this.controllerFor("chat-channel-thread").get("targetMessageId")
|
|
) {
|
|
this.controllerFor("chat-channel-thread").set("targetMessageId", null);
|
|
}
|
|
}
|
|
}
|