A platform for community discussion. Free, open, simple.
FIX: Conditionally hide 'My Threads' on mobile (#25494)
Jan Cernik9b9ff3e10a08
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-footer.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-footer.gjsindex fb43022b311..2d7ed5fea29 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-footer.gjs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-footer.gjs@@ -14,15 +14,23 @@ export default class ChatFooter extends Component {@service router;@service chat;@service siteSettings;+ @service currentUser;- threadsEnabled = this.siteSettings.chat_threads_enabled;+ get includeThreads() {+ if (!this.siteSettings.chat_threads_enabled) {+ return false;+ }+ return this.currentUser?.chat_channels?.public_channels?.some(+ (channel) => channel.threading_enabled+ );+ }get directMessagesEnabled() {return this.chat.userCanAccessDirectMessages;}get shouldRenderFooter() {- return this.threadsEnabled || this.directMessagesEnabled;+ return this.includeThreads || this.directMessagesEnabled;}<template>@@ -63,7 +71,7 @@ export default class ChatFooter extends Component {</DButton>{{/if}}- {{#if this.threadsEnabled}}+ {{#if this.includeThreads}}<DButton@route="chat.threads"@icon="discourse-threads"diff --git a/plugins/chat/spec/system/chat_footer_spec.rb b/plugins/chat/spec/system/chat_footer_spec.rbindex c2ff04fe284..520cdd25651 100644--- a/plugins/chat/spec/system/chat_footer_spec.rb+++ b/plugins/chat/spec/system/chat_footer_spec.rb@@ -40,14 +40,34 @@ RSpec.describe "Mobile Chat footer", type: :system, mobile: true doexpect(page).to have_current_path("/chat/channels")end- it "shows threads tab when user has threads" do- SiteSetting.chat_threads_enabled = true+ context "when user is a member of at least one channel with threads" do+ it "shows threads tab when user has threads" do+ SiteSetting.chat_threads_enabled = true- visit("/")- chat_page.open_from_header+ visit("/")+ chat_page.open_from_header- expect(page).to have_css(".c-footer")- expect(page).to have_css("#c-footer-threads")+ expect(page).to have_css(".c-footer")+ expect(page).to have_css("#c-footer-threads")+ end+ end++ context "when user is not a member of any channel with threads" do+ before do+ other_channel = Fabricate(:chat_channel, threading_enabled: false)+ other_channel.add(user)+ channel.remove(user)+ end++ it "shows threads tab when user has threads" do+ SiteSetting.chat_threads_enabled = true++ visit("/")+ chat_page.open_from_header++ expect(page).to have_css(".c-footer")+ expect(page).to have_no_css("#c-footer-threads")+ endendend