FIX: Conditionally hide 'My Threads' on mobile (#25494)

This commit is contained in:
Jan Cernik 2024-01-31 09:09:04 -03:00 committed by GitHub
parent 52249fad11
commit 9b9ff3e10a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 9 deletions

View File

@ -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"

View File

@ -40,14 +40,34 @@ RSpec.describe "Mobile Chat footer", type: :system, mobile: true do
expect(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")
end
end
end