FIX: Conditionally hide 'My Threads' on mobile (#25494)
This commit is contained in:
parent
52249fad11
commit
9b9ff3e10a
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue