A platform for community discussion. Free, open, simple.
FIX: set channels tab as default on mobile chat footer (#25296)
David Battersby6876c52857a2
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-footer.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-footer.gjsindex a7906c2069c..fd7726bb899 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-footer.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-footer.gjs@@ -42,6 +42,19 @@ export default class ChatFooter extends Component {<template>{{#if this.shouldRenderFooter}}<nav class="c-footer" {{this.updateThreadCount}}>+ <DButton+ @route="chat.channels"+ @class={{concatClass+ "btn-flat"+ "c-footer__item"+ (if (eq this.router.currentRouteName "chat.channels") "--active")+ }}+ @icon="comments"+ @id="c-footer-channels"+ @translatedLabel={{i18n "chat.channel_list.title"}}+ aria-label={{i18n "chat.channel_list.aria_label"}}+ />+{{#if this.directMessagesEnabled}}<DButton@route="chat.direct-messages"@@ -60,19 +73,6 @@ export default class ChatFooter extends Component {/>{{/if}}- <DButton- @route="chat.channels"- @class={{concatClass- "btn-flat"- "c-footer__item"- (if (eq this.router.currentRouteName "chat.channels") "--active")- }}- @icon="comments"- @id="c-footer-channels"- @translatedLabel={{i18n "chat.channel_list.title"}}- aria-label={{i18n "chat.channel_list.aria_label"}}- />-{{#if this.threadsEnabled}}<DButton@route="chat.threads"diff --git a/plugins/chat/assets/javascripts/discourse/routes/chat-index.js b/plugins/chat/assets/javascripts/discourse/routes/chat-index.jsindex 458f777f31c..7955f8f3506 100644--- a/plugins/chat/assets/javascripts/discourse/routes/chat-index.js+++ b/plugins/chat/assets/javascripts/discourse/routes/chat-index.js@@ -13,11 +13,7 @@ export default class ChatIndexRoute extends DiscourseRoute {redirect() {// on mobile redirect user to the first footer tab routeif (this.site.mobileView) {- if (this.chat.userCanAccessDirectMessages) {- return this.router.replaceWith("chat.direct-messages");- } else {- return this.router.replaceWith("chat.channels");- }+ return this.router.replaceWith("chat.channels");}// We are on desktop. Check for a channel to enter and transition if sodiff --git a/plugins/chat/spec/system/browse_page_spec.rb b/plugins/chat/spec/system/browse_page_spec.rbindex 09d236ae7e2..e78b103ed4d 100644--- a/plugins/chat/spec/system/browse_page_spec.rb+++ b/plugins/chat/spec/system/browse_page_spec.rb@@ -69,7 +69,7 @@ RSpec.describe "Browse page", type: :system dochat_page.visit_browsefind(".c-navbar__back-button").click- expect(browse_page).to have_current_path("/chat/direct-messages")+ expect(browse_page).to have_current_path("/chat/channels")endenddiff --git a/plugins/chat/spec/system/chat_footer_spec.rb b/plugins/chat/spec/system/chat_footer_spec.rbindex fede8ebe557..5b028c5f0ab 100644--- a/plugins/chat/spec/system/chat_footer_spec.rb+++ b/plugins/chat/spec/system/chat_footer_spec.rb@@ -29,11 +29,11 @@ RSpec.describe "Chat footer on mobile", type: :system, mobile: true doexpect(page).to have_no_css(".c-footer")end- it "redirects the user to the direct messages tab" do+ it "redirects the user to the channels tab" dovisit("/")chat_page.open_from_header- expect(page).to have_current_path("/chat/direct-messages")+ expect(page).to have_current_path("/chat/channels")endit "shows threads tab when user has threads" dodiff --git a/plugins/chat/spec/system/list_channels/mobile_spec.rb b/plugins/chat/spec/system/list_channels/mobile_spec.rbindex 920d5cbd57f..a9820c89555 100644--- a/plugins/chat/spec/system/list_channels/mobile_spec.rb+++ b/plugins/chat/spec/system/list_channels/mobile_spec.rb@@ -63,7 +63,7 @@ RSpec.describe "List channels | mobile", type: :system, mobile: true docontext "when member of the channel" doit "shows the channel in the correct section" do- visit("/chat")+ visit("/chat/direct-messages")expect(page.find(".direct-message-channels")).to have_content(current_user.username)endenddiff --git a/plugins/chat/spec/system/message_notifications_mobile_spec.rb b/plugins/chat/spec/system/message_notifications_mobile_spec.rbindex 7c3c2bde436..483c2b868f4 100644--- a/plugins/chat/spec/system/message_notifications_mobile_spec.rb+++ b/plugins/chat/spec/system/message_notifications_mobile_spec.rb@@ -118,7 +118,7 @@ RSpec.describe "Message notifications - mobile", type: :system, mobile: true docontext "when a message is created" doit "correctly renders notifications" do- visit("/chat")+ visit("/chat/direct-messages")create_message(dm_channel_1, user: user_1)@@ -139,7 +139,7 @@ RSpec.describe "Message notifications - mobile", type: :system, mobile: true doendit "reorders channels" do- visit("/chat")+ visit("/chat/direct-messages")expect(page).to have_css(".chat-channel-row:nth-child(1)[data-chat-channel-id=\"#{dm_channel_1.id}\"]",diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rbindex 7912d836808..166198a6bf6 100644--- a/plugins/chat/spec/system/navigation_spec.rb+++ b/plugins/chat/spec/system/navigation_spec.rb@@ -38,11 +38,11 @@ RSpec.describe "Navigation", type: :system doendcontext "when clicking chat icon on mobile and is viewing channel" do- it "navigates to direct messages tab", mobile: true do+ it "navigates to channels tab", mobile: true dochat_page.visit_channel(category_channel_2)chat_page.open_from_header- expect(page).to have_current_path("/chat/direct-messages")+ expect(page).to have_current_path("/chat/channels")endend