import Component from "@glimmer/component"; import { service } from "@ember/service"; import { eq } from "truth-helpers"; import DButton from "discourse/components/d-button"; import concatClass from "discourse/helpers/concat-class"; import i18n from "discourse-common/helpers/i18n"; import { UnreadChannelsIndicator, UnreadDirectMessagesIndicator, UnreadThreadsIndicator, } from "discourse/plugins/chat/discourse/components/chat/footer/unread-indicator"; export default class ChatFooter extends Component { @service router; @service chat; @service chatHistory; @service siteSettings; @service site; @service currentUser; @service chatChannelsManager; @service chatStateManager; get includeThreads() { if (!this.siteSettings.chat_threads_enabled) { return false; } return this.chatChannelsManager.hasThreadedChannels; } get directMessagesEnabled() { return this.chat.userCanAccessDirectMessages; } get currentRouteName() { const routeName = this.chatHistory.currentRoute?.name; return routeName === "chat" ? "chat.channels" : routeName; } get enabledRouteCount() { return [ this.includeThreads, this.directMessagesEnabled, this.siteSettings.enable_public_channels, ].filter(Boolean).length; } get shouldRenderFooter() { return ( (this.site.mobileView || this.chatStateManager.isDrawerExpanded) && this.chatStateManager.hasPreloadedChannels && this.enabledRouteCount > 1 ); } }