FIX: add desktop redirect for mobile only chat routes (#25561)
Chat mobile has separate routes for channels and direct messages. However on desktop we want to prevent these routes from being accessible as they aren't intended to be used by chat in full-page or drawer mode on desktop.
This commit is contained in:
parent
ac53e5a962
commit
4b85975490
|
@ -9,6 +9,12 @@ export default class ChatChannelsRoute extends DiscourseRoute {
|
|||
this.chat.activeChannel = null;
|
||||
}
|
||||
|
||||
beforeModel() {
|
||||
if (this.site.desktopView) {
|
||||
this.router.transitionTo("chat");
|
||||
}
|
||||
}
|
||||
|
||||
model() {
|
||||
return this.chatChannelsManager.publicMessageChannels;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,12 @@ export default class ChatDirectMessagesRoute extends DiscourseRoute {
|
|||
this.chat.activeChannel = null;
|
||||
}
|
||||
|
||||
beforeModel() {
|
||||
if (this.site.desktopView) {
|
||||
this.router.transitionTo("chat");
|
||||
}
|
||||
}
|
||||
|
||||
model() {
|
||||
return this.chatChannelsManager.directMessageChannels;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,24 @@ RSpec.describe "Navigation", type: :system do
|
|||
end
|
||||
end
|
||||
|
||||
context "when visiting mobile only routes on desktop" do
|
||||
it "redirects /chat/channels to ideal first channel" do
|
||||
visit("/chat/channels")
|
||||
|
||||
expect(page).to have_current_path(
|
||||
chat.channel_path(category_channel.slug, category_channel.id),
|
||||
)
|
||||
end
|
||||
|
||||
it "redirects /chat/direct-messages to ideal first channel" do
|
||||
visit("/chat/direct-messages")
|
||||
|
||||
expect(page).to have_current_path(
|
||||
chat.channel_path(category_channel.slug, category_channel.id),
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "when opening chat" do
|
||||
it "opens the drawer by default" do
|
||||
visit("/")
|
||||
|
|
Loading…
Reference in New Issue