A platform for community discussion. Free, open, simple.
DEV: prevent duplication of chat drawer routes (#27381)
David Battersby9e6dc4c5c808
diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat.js b/plugins/chat/assets/javascripts/discourse/routes/chat.jsindex 8a7e5202f74..c2e969d7568 100644--- a/plugins/chat/assets/javascripts/discourse/routes/chat.js+++ b/plugins/chat/assets/javascripts/discourse/routes/chat.js@@ -15,6 +15,7 @@ export default class ChatRoute extends DiscourseRoute {@service chat;@service router;@service chatStateManager;+ @service chatDrawerRouter;@service currentUser;titleToken() {@@ -26,29 +27,10 @@ export default class ChatRoute extends DiscourseRoute {return this.router.transitionTo(`discovery.${defaultHomepage()}`);}- const INTERCEPTABLE_ROUTES = [- "chat.channel",- "chat.direct-messages",- "chat.channels",- "chat.threads",- "chat.channel.thread",- "chat.channel.thread.index",- "chat.channel.thread.near-message",- "chat.channel.near-message-with-thread",- "chat.channel.threads",- "chat.channel.index",- "chat.channel.near-message",- "chat.channel-legacy",- "chat.channel.info.settings",- "chat.channel.info.members",- "chat",- "chat.index",- ];-if (transition.from && // don't intercept when directly loading chatthis.chatStateManager.isDrawerPreferred &&- INTERCEPTABLE_ROUTES.includes(transition.targetName)+ this.chatDrawerRouter.routeNames.includes(transition.targetName)) {transition.abort();diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js b/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.jsindex 1342dee11c9..40693b71420 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat-drawer-router.js@@ -9,7 +9,9 @@ import ChatDrawerRoutesSettings from "discourse/plugins/chat/discourse/componentimport ChatDrawerRoutesThreads from "discourse/plugins/chat/discourse/components/chat/drawer-routes/threads";const ROUTES = {+ "chat.index": { name: ChatDrawerRoutesChannels },"chat.channel": { name: ChatDrawerRoutesChannel },+ "chat.channel.index": { name: ChatDrawerRoutesChannel },"chat.channel.thread": {name: ChatDrawerRoutesChannelThread,extractParams: (route) => {@@ -103,6 +105,8 @@ export default class ChatDrawerRouter extends Service {@tracked drawerRoute = null;@tracked params = null;+ routeNames = Object.keys(ROUTES);+stateFor(route) {this.drawerRoute?.deactivate?.(this.chatHistory.currentRoute);