mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
FIX: Conditionally hide 'My Threads' on mobile (#25494)
This commit is contained in:
@ -14,15 +14,23 @@ export default class ChatFooter extends Component {
|
|||||||
@service router;
|
@service router;
|
||||||
@service chat;
|
@service chat;
|
||||||
@service siteSettings;
|
@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() {
|
get directMessagesEnabled() {
|
||||||
return this.chat.userCanAccessDirectMessages;
|
return this.chat.userCanAccessDirectMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
get shouldRenderFooter() {
|
get shouldRenderFooter() {
|
||||||
return this.threadsEnabled || this.directMessagesEnabled;
|
return this.includeThreads || this.directMessagesEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -63,7 +71,7 @@ export default class ChatFooter extends Component {
|
|||||||
</DButton>
|
</DButton>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if this.threadsEnabled}}
|
{{#if this.includeThreads}}
|
||||||
<DButton
|
<DButton
|
||||||
@route="chat.threads"
|
@route="chat.threads"
|
||||||
@icon="discourse-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")
|
expect(page).to have_current_path("/chat/channels")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows threads tab when user has threads" do
|
context "when user is a member of at least one channel with threads" do
|
||||||
SiteSetting.chat_threads_enabled = true
|
it "shows threads tab when user has threads" do
|
||||||
|
SiteSetting.chat_threads_enabled = true
|
||||||
|
|
||||||
visit("/")
|
visit("/")
|
||||||
chat_page.open_from_header
|
chat_page.open_from_header
|
||||||
|
|
||||||
expect(page).to have_css(".c-footer")
|
expect(page).to have_css(".c-footer")
|
||||||
expect(page).to have_css("#c-footer-threads")
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user