This commit allows the user to set their preference vis-a-vis the chat icon in the header of the page. There are three options: - All New (default) - This maintains the existing behaviour where all new messages in the channel show a blue dot on the icon - Direct Messages and Mentions - Only show the green dot on the icon when you are directly messaged or mentioned, the blue dot is never shown - Never - Never show any dot on the chat icon, for those who want tractor-beam-laser-focus
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
import { inject as service } from "@ember/service";
|
|
import Component from "@glimmer/component";
|
|
import {
|
|
HEADER_INDICATOR_PREFERENCE_ALL_NEW,
|
|
HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS,
|
|
HEADER_INDICATOR_PREFERENCE_NEVER,
|
|
} from "../controllers/preferences-chat";
|
|
|
|
export default class ChatHeaderIconUnreadIndicator extends Component {
|
|
@service chatChannelsManager;
|
|
@service currentUser;
|
|
|
|
get showUrgentIndicator() {
|
|
return (
|
|
this.chatChannelsManager.unreadUrgentCount > 0 &&
|
|
this.#hasAnyIndicatorPreference([
|
|
HEADER_INDICATOR_PREFERENCE_ALL_NEW,
|
|
HEADER_INDICATOR_PREFERENCE_DM_AND_MENTIONS,
|
|
])
|
|
);
|
|
}
|
|
|
|
get showUnreadIndicator() {
|
|
return (
|
|
this.chatChannelsManager.unreadCount > 0 &&
|
|
this.#hasAnyIndicatorPreference([HEADER_INDICATOR_PREFERENCE_ALL_NEW])
|
|
);
|
|
}
|
|
|
|
get indicatorPreference() {
|
|
return this.currentUser.user_option.chat_header_indicator_preference;
|
|
}
|
|
|
|
#hasAnyIndicatorPreference(preferences) {
|
|
if (
|
|
!this.currentUser ||
|
|
this.indicatorPreference === HEADER_INDICATOR_PREFERENCE_NEVER
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return preferences.includes(this.indicatorPreference);
|
|
}
|
|
}
|