FIX: Intercept old channel URLs in drawer mode (#20043)

This commit is contained in:
Roman Rizzi 2023-01-27 17:46:53 -03:00 committed by GitHub
parent a4c68d4a2e
commit 7441864474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 17 deletions

View File

@ -211,6 +211,17 @@ export default Component.extend({
URL || this.chatStateManager.lastKnownChatURL
);
let highlightCb = null;
if (route.queryParams.messageId) {
highlightCb = () => {
this.appEvents.trigger(
"chat-live-pane:highlight-message",
route.queryParams.messageId
);
};
}
switch (route.name) {
case "chat":
this.set("view", LIST_VIEW);
@ -221,25 +232,26 @@ export default Component.extend({
this.appEvents.trigger("chat:float-toggled", false);
return;
case "chat.channel":
return this.chatChannelsManager
.find(route.params.channelId)
.then((channel) => {
this.chat.setActiveChannel(channel);
this.set("view", CHAT_VIEW);
this.appEvents.trigger("chat:float-toggled", false);
if (route.queryParams.messageId) {
schedule("afterRender", () => {
this.appEvents.trigger(
"chat-live-pane:highlight-message",
route.queryParams.messageId
);
});
}
});
return this._openChannel(route, highlightCb);
case "chat.channel-legacy":
return this._openChannel(route, highlightCb);
}
},
_openChannel(route, afterRenderFunc = null) {
return this.chatChannelsManager
.find(route.params.channelId)
.then((channel) => {
this.chat.setActiveChannel(channel);
this.set("view", CHAT_VIEW);
this.appEvents.trigger("chat:float-toggled", false);
if (afterRenderFunc) {
schedule("afterRender", afterRenderFunc);
}
});
},
@action
openInFullPage() {
this.chatStateManager.storeAppURL();

View File

@ -16,6 +16,7 @@ export default class ChatChannelRoute extends DiscourseRoute {
this.chat.setActiveChannel(model);
const { channelTitle, messageId } = this.paramsFor(this.routeName);
if (channelTitle !== model.slugifiedTitle) {
this.router.replaceWith("chat.channel.index", ...model.routeModels, {
queryParams: { messageId },

View File

@ -23,6 +23,7 @@ export default class ChatRoute extends DiscourseRoute {
const INTERCEPTABLE_ROUTES = [
"chat.channel.index",
"chat.channel",
"chat.channel-legacy",
"chat",
"chat.index",
"chat.draft-channel",
@ -36,7 +37,10 @@ export default class ChatRoute extends DiscourseRoute {
transition.abort();
let URL = transition.intent.url;
if (transition.targetName.startsWith("chat.channel")) {
if (
transition.targetName.startsWith("chat.channel") ||
transition.targetName.startsWith("chat.channel-legacy")
) {
URL ??= this.router.urlFor(
transition.targetName,
...transition.intent.contexts