A platform for community discussion. Free, open, simple.
UX: default to starred channels when opening chat (#36562)
Régis Hanolf06fd595f6d8
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-state-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-state-manager.jsindex c3355b80979..517acfcc48a 100644--- a/plugins/chat/assets/javascripts/discourse/services/chat-state-manager.js+++ b/plugins/chat/assets/javascripts/discourse/services/chat-state-manager.js@@ -24,6 +24,7 @@ export function resetChatDrawerStateCallbacks() {export default class ChatStateManager extends Service {@service chat;+ @service chatChannelsManager;@service router;@service site;@service chatDrawerRouter;@@ -189,7 +190,15 @@ export default class ChatStateManager extends Service {}get lastKnownChatURL() {- return this._chatURL || "/chat";+ if (this._chatURL) {+ return this._chatURL;+ }++ if (this.chatChannelsManager.hasStarredChannels) {+ return "/chat/starred-channels";+ }++ return "/chat";}#publishStateChange() {diff --git a/plugins/chat/spec/system/starred_channels_spec.rb b/plugins/chat/spec/system/starred_channels_spec.rbindex e896212eb61..c5ef6f45a98 100644--- a/plugins/chat/spec/system/starred_channels_spec.rb+++ b/plugins/chat/spec/system/starred_channels_spec.rb@@ -343,6 +343,34 @@ RSpec.describe "Starred channels", type: :system doendend+ context "when opening chat without a known last location" do+ fab!(:channel_1) { Fabricate(:category_channel, name: "Channel A") }++ before { channel_1.add(current_user) }++ context "when user has starred channels" do+ before { channel_1.membership_for(current_user).update!(starred: true) }++ it "opens to starred channels" do+ visit("/")+ chat_page.prefers_full_page+ chat_page.open_from_header++ expect(page).to have_current_path("/chat/starred-channels")+ end+ end++ context "when user has no starred channels" do+ it "opens to the default chat index" do+ visit("/")+ chat_page.prefers_full_page+ chat_page.open_from_header++ expect(page).to have_current_path("/chat/browse/open")+ end+ end+ end+context "when navigating from starred channels on mobile", mobile: true dofab!(:user_1, :user)fab!(:channel_1) { Fabricate(:category_channel, name: "Channel A") }