diff --git a/res/css/views/rooms/_LegacyRoomHeader.pcss b/res/css/views/rooms/_LegacyRoomHeader.pcss index d9d2f4b22d1..9994f4223ea 100644 --- a/res/css/views/rooms/_LegacyRoomHeader.pcss +++ b/res/css/views/rooms/_LegacyRoomHeader.pcss @@ -212,17 +212,17 @@ limitations under the License. top: var(--RoomHeader-indicator-dot-offset); margin: 4px; - &.mx_Indicator_red { + &.mx_Indicator_highlight { background: $alert; box-shadow: $alert; } - &.mx_Indicator_gray { + &.mx_Indicator_notification { background: $room-icon-unread-color; box-shadow: $room-icon-unread-color; } - &.mx_Indicator_bold { + &.mx_Indicator_activity { background: $primary-content; box-shadow: $primary-content; } diff --git a/res/css/views/rooms/_ThreadSummary.pcss b/res/css/views/rooms/_ThreadSummary.pcss index 78a9d9e5292..ccfc527974c 100644 --- a/res/css/views/rooms/_ThreadSummary.pcss +++ b/res/css/views/rooms/_ThreadSummary.pcss @@ -83,11 +83,6 @@ limitations under the License. } } - &::before { - @mixin ThreadSummaryIcon; - align-self: center; /* v-align the threads icon */ - } - .mx_ThreadSummary_sender, .mx_ThreadSummary_content, .mx_ThreadSummary_replies_amount { diff --git a/src/RoomNotifs.ts b/src/RoomNotifs.ts index aa696f6e29c..7a65acadfc8 100644 --- a/src/RoomNotifs.ts +++ b/src/RoomNotifs.ts @@ -24,7 +24,7 @@ import { } from "matrix-js-sdk/src/matrix"; import type { IPushRule, Room, MatrixClient } from "matrix-js-sdk/src/matrix"; -import { NotificationColor } from "./stores/notifications/NotificationColor"; +import { NotificationLevel } from "./stores/notifications/NotificationLevel"; import { getUnsentMessages } from "./components/structures/RoomStatusBar"; import { doesRoomHaveUnreadMessages, doesRoomOrThreadHaveUnreadMessages } from "./Unread"; import { EffectiveMembership, getEffectiveMembership, isKnockDenied } from "./utils/membership"; @@ -227,25 +227,25 @@ function isMuteRule(rule: IPushRule): boolean { export function determineUnreadState( room?: Room, threadId?: string, -): { color: NotificationColor; symbol: string | null; count: number } { +): { level: NotificationLevel; symbol: string | null; count: number } { if (!room) { - return { symbol: null, count: 0, color: NotificationColor.None }; + return { symbol: null, count: 0, level: NotificationLevel.None }; } if (getUnsentMessages(room, threadId).length > 0) { - return { symbol: "!", count: 1, color: NotificationColor.Unsent }; + return { symbol: "!", count: 1, level: NotificationLevel.Unsent }; } if (getEffectiveMembership(room.getMyMembership()) === EffectiveMembership.Invite) { - return { symbol: "!", count: 1, color: NotificationColor.Red }; + return { symbol: "!", count: 1, level: NotificationLevel.Highlight }; } if (SettingsStore.getValue("feature_ask_to_join") && isKnockDenied(room)) { - return { symbol: "!", count: 1, color: NotificationColor.Red }; + return { symbol: "!", count: 1, level: NotificationLevel.Highlight }; } if (getRoomNotifsState(room.client, room.roomId) === RoomNotifState.Mute) { - return { symbol: null, count: 0, color: NotificationColor.None }; + return { symbol: null, count: 0, level: NotificationLevel.None }; } const redNotifs = getUnreadNotificationCount(room, NotificationCountType.Highlight, threadId); @@ -253,11 +253,11 @@ export function determineUnreadState( const trueCount = greyNotifs || redNotifs; if (redNotifs > 0) { - return { symbol: null, count: trueCount, color: NotificationColor.Red }; + return { symbol: null, count: trueCount, level: NotificationLevel.Highlight }; } if (greyNotifs > 0) { - return { symbol: null, count: trueCount, color: NotificationColor.Grey }; + return { symbol: null, count: trueCount, level: NotificationLevel.Notification }; } // We don't have any notified messages, but we might have unread messages. Let's find out. @@ -275,6 +275,6 @@ export function determineUnreadState( return { symbol: null, count: trueCount, - color: hasUnread ? NotificationColor.Bold : NotificationColor.None, + level: hasUnread ? NotificationLevel.Activity : NotificationLevel.None, }; } diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index c998989599b..4c11595d8b4 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -140,7 +140,7 @@ import GenericToast from "../views/toasts/GenericToast"; import RovingSpotlightDialog from "../views/dialogs/spotlight/SpotlightDialog"; import { findDMForUser } from "../../utils/dm/findDMForUser"; import { Linkify } from "../../HtmlUtils"; -import { NotificationColor } from "../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../stores/notifications/NotificationLevel"; import { UserTab } from "../views/dialogs/UserTab"; import { shouldSkipSetupEncryption } from "../../utils/crypto/shouldSkipSetupEncryption"; import { Filter } from "../views/dialogs/spotlight/Filter"; @@ -2019,7 +2019,7 @@ export default class MatrixChat extends React.PureComponent { } if (numUnreadRooms > 0) { this.subTitleStatus += `[${numUnreadRooms}]`; - } else if (notificationState.color >= NotificationColor.Bold) { + } else if (notificationState.level >= NotificationLevel.Activity) { this.subTitleStatus += `*`; } diff --git a/src/components/views/context_menus/RoomGeneralContextMenu.tsx b/src/components/views/context_menus/RoomGeneralContextMenu.tsx index 8e96c028704..4cfd2ed6040 100644 --- a/src/components/views/context_menus/RoomGeneralContextMenu.tsx +++ b/src/components/views/context_menus/RoomGeneralContextMenu.tsx @@ -26,7 +26,7 @@ import { useEventEmitterState } from "../../../hooks/useEventEmitter"; import { useUnreadNotifications } from "../../../hooks/useUnreadNotifications"; import { getKeyBindingsManager } from "../../../KeyBindingsManager"; import { _t } from "../../../languageHandler"; -import { NotificationColor } from "../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../stores/notifications/NotificationLevel"; import { DefaultTagID, TagID } from "../../../stores/room-list/models"; import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore"; import DMRoomMap from "../../../utils/DMRoomMap"; @@ -212,9 +212,9 @@ export const RoomGeneralContextMenu: React.FC = ({ ); } - const { color } = useUnreadNotifications(room); + const { level } = useUnreadNotifications(room); const markAsReadOption: JSX.Element | null = - color > NotificationColor.None ? ( + level > NotificationLevel.None ? ( { clearRoomNotification(room, cli); diff --git a/src/components/views/dialogs/devtools/RoomNotifications.tsx b/src/components/views/dialogs/devtools/RoomNotifications.tsx index f1bd13647f7..5a43eeb935e 100644 --- a/src/components/views/dialogs/devtools/RoomNotifications.tsx +++ b/src/components/views/dialogs/devtools/RoomNotifications.tsx @@ -22,7 +22,7 @@ import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import { useNotificationState } from "../../../../hooks/useRoomNotificationState"; import { _t, _td } from "../../../../languageHandler"; import { determineUnreadState } from "../../../../RoomNotifs"; -import { humanReadableNotificationColor } from "../../../../stores/notifications/NotificationColor"; +import { humanReadableNotificationLevel } from "../../../../stores/notifications/NotificationLevel"; import { doesRoomOrThreadHaveUnreadMessages } from "../../../../Unread"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; @@ -68,7 +68,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme const { room } = useContext(DevtoolsContext); const cli = useContext(MatrixClientContext); - const { color, count } = determineUnreadState(room); + const { level, count } = determineUnreadState(room); const [notificationState] = useNotificationState(room); return ( @@ -81,7 +81,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme ? _t( "devtools|room_unread_status_count", { - status: humanReadableNotificationColor(color), + status: humanReadableNotificationLevel(level), count, }, { @@ -91,7 +91,7 @@ export default function RoomNotifications({ onBack }: IDevtoolsProps): JSX.Eleme : _t( "devtools|room_unread_status", { - status: humanReadableNotificationColor(color), + status: humanReadableNotificationLevel(level), }, { strong: (sub) => {sub}, diff --git a/src/components/views/right_panel/HeaderButtons.tsx b/src/components/views/right_panel/HeaderButtons.tsx index dbdd2f10b5b..35c2275adef 100644 --- a/src/components/views/right_panel/HeaderButtons.tsx +++ b/src/components/views/right_panel/HeaderButtons.tsx @@ -24,7 +24,7 @@ import dis from "../../../dispatcher/dispatcher"; import RightPanelStore from "../../../stores/right-panel/RightPanelStore"; import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases"; import { UPDATE_EVENT } from "../../../stores/AsyncStore"; -import { NotificationColor } from "../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../stores/notifications/NotificationLevel"; import SettingsStore from "../../../settings/SettingsStore"; export enum HeaderKind { @@ -34,8 +34,8 @@ export enum HeaderKind { interface IState { headerKind: HeaderKind; phase: RightPanelPhases | null; - threadNotificationColor: NotificationColor; - globalNotificationColor: NotificationColor; + threadNotificationLevel: NotificationLevel; + globalNotificationLevel: NotificationLevel; notificationsEnabled?: boolean; } @@ -53,8 +53,8 @@ export default abstract class HeaderButtons

extends React.Component diff --git a/src/components/views/right_panel/LegacyRoomHeaderButtons.tsx b/src/components/views/right_panel/LegacyRoomHeaderButtons.tsx index b5117d7dec1..672a2886564 100644 --- a/src/components/views/right_panel/LegacyRoomHeaderButtons.tsx +++ b/src/components/views/right_panel/LegacyRoomHeaderButtons.tsx @@ -35,7 +35,7 @@ import { RoomNotificationStateStore, UPDATE_STATUS_INDICATOR, } from "../../../stores/notifications/RoomNotificationStateStore"; -import { NotificationColor } from "../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../stores/notifications/NotificationLevel"; import { SummarizedNotificationState } from "../../../stores/notifications/SummarizedNotificationState"; import PosthogTrackers from "../../../PosthogTrackers"; import { ButtonEvent } from "../elements/AccessibleButton"; @@ -52,20 +52,20 @@ const ROOM_INFO_PHASES = [ ]; interface IUnreadIndicatorProps { - color?: NotificationColor; + color?: NotificationLevel; } const UnreadIndicator: React.FC = ({ color }) => { - if (color === NotificationColor.None) { + if (color === NotificationLevel.None) { return null; } const classes = classNames({ mx_Indicator: true, mx_LegacyRoomHeader_button_unreadIndicator: true, - mx_Indicator_bold: color === NotificationColor.Bold, - mx_Indicator_gray: color === NotificationColor.Grey, - mx_Indicator_red: color === NotificationColor.Red, + mx_Indicator_activity: color === NotificationLevel.Activity, + mx_Indicator_notification: color === NotificationLevel.Notification, + mx_Indicator_highlight: color === NotificationLevel.Highlight, }); return ( <> @@ -106,11 +106,11 @@ const PinnedMessagesHeaderButton: React.FC = ({ room, isHigh const TimelineCardHeaderButton: React.FC = ({ room, isHighlighted, onClick }) => { let unreadIndicator; - const color = RoomNotificationStateStore.instance.getRoomState(room).color; + const color = RoomNotificationStateStore.instance.getRoomState(room).level; switch (color) { - case NotificationColor.Bold: - case NotificationColor.Grey: - case NotificationColor.Red: + case NotificationLevel.Activity: + case NotificationLevel.Notification: + case NotificationLevel.Highlight: unreadIndicator = ; } return ( @@ -174,36 +174,36 @@ export default class LegacyRoomHeaderButtons extends HeaderButtons { private onNotificationUpdate = (): void => { // console.log - // XXX: why don't we read from this.state.threadNotificationColor in the render methods? + // XXX: why don't we read from this.state.threadNotificationLevel in the render methods? this.setState({ - threadNotificationColor: this.notificationColor, + threadNotificationLevel: this.notificationLevel, }); }; - private get notificationColor(): NotificationColor { + private get notificationLevel(): NotificationLevel { switch (this.props.room?.threadsAggregateNotificationType) { case NotificationCountType.Highlight: - return NotificationColor.Red; + return NotificationLevel.Highlight; case NotificationCountType.Total: - return NotificationColor.Grey; + return NotificationLevel.Notification; } // We don't have any notified messages, but we might have unread messages. Let's // find out. for (const thread of this.props.room!.getThreads()) { // If the current thread has unread messages, we're done. if (doesRoomOrThreadHaveUnreadMessages(thread)) { - return NotificationColor.Bold; + return NotificationLevel.Activity; } } // Otherwise, no notification color. - return NotificationColor.None; + return NotificationLevel.None; } private onUpdateStatus = (notificationState: SummarizedNotificationState): void => { // XXX: why don't we read from this.state.globalNotificationCount in the render methods? this.globalNotificationState = notificationState; this.setState({ - globalNotificationColor: notificationState.color, + globalNotificationLevel: notificationState.level, }); }; @@ -282,9 +282,9 @@ export default class LegacyRoomHeaderButtons extends HeaderButtons { title={_t("common|threads")} onClick={this.onThreadsPanelClicked} isHighlighted={this.isPhase(LegacyRoomHeaderButtons.THREAD_PHASES)} - isUnread={this.state.threadNotificationColor > NotificationColor.None} + isUnread={this.state.threadNotificationLevel > NotificationLevel.None} > - + , ); if (this.state.notificationsEnabled) { @@ -296,10 +296,10 @@ export default class LegacyRoomHeaderButtons extends HeaderButtons { title={_t("notifications|enable_prompt_toast_title")} isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)} onClick={this.onNotificationsClicked} - isUnread={this.globalNotificationState.color === NotificationColor.Red} + isUnread={this.globalNotificationState.level === NotificationLevel.Highlight} > - {this.globalNotificationState.color === NotificationColor.Red ? ( - + {this.globalNotificationState.level === NotificationLevel.Highlight ? ( + ) : null} , ); diff --git a/src/components/views/rooms/NotificationBadge.tsx b/src/components/views/rooms/NotificationBadge.tsx index a8a34c17d4b..d152ab6a626 100644 --- a/src/components/views/rooms/NotificationBadge.tsx +++ b/src/components/views/rooms/NotificationBadge.tsx @@ -21,7 +21,7 @@ import SettingsStore from "../../../settings/SettingsStore"; import { XOR } from "../../../@types/common"; import { NotificationState, NotificationStateEvents } from "../../../stores/notifications/NotificationState"; import { _t } from "../../../languageHandler"; -import { NotificationColor } from "../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../stores/notifications/NotificationLevel"; import { StatelessNotificationBadge } from "./NotificationBadge/StatelessNotificationBadge"; interface IProps { @@ -107,7 +107,7 @@ export default class NotificationBadge extends React.PureComponent = { symbol: notification.symbol, count: notification.count, - color: notification.color, + level: notification.level, knocked: notification.knocked, }; @@ -118,7 +118,7 @@ export default class NotificationBadge extends React.PureComponent; } - if (showUnsentTooltip && notification.color === NotificationColor.Unsent) { + if (showUnsentTooltip && notification.level === NotificationLevel.Unsent) { return ( {badge} diff --git a/src/components/views/rooms/NotificationBadge/StatelessNotificationBadge.tsx b/src/components/views/rooms/NotificationBadge/StatelessNotificationBadge.tsx index 76f1d8e8389..95f71cc085e 100644 --- a/src/components/views/rooms/NotificationBadge/StatelessNotificationBadge.tsx +++ b/src/components/views/rooms/NotificationBadge/StatelessNotificationBadge.tsx @@ -19,14 +19,14 @@ import classNames from "classnames"; import { formatCount } from "../../../../utils/FormattingUtils"; import AccessibleButton, { ButtonEvent } from "../../elements/AccessibleButton"; -import { NotificationColor } from "../../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../stores/notifications/NotificationLevel"; import { useSettingValue } from "../../../../hooks/useSettings"; import { XOR } from "../../../../@types/common"; interface Props { symbol: string | null; count: number; - color: NotificationColor; + level: NotificationLevel; knocked?: boolean; } @@ -39,15 +39,15 @@ interface ClickableProps extends Props { } export const StatelessNotificationBadge = forwardRef>( - ({ symbol, count, color, knocked, ...props }, ref) => { + ({ symbol, count, level, knocked, ...props }, ref) => { const hideBold = useSettingValue("feature_hidebold"); // Don't show a badge if we don't need to - if ((color === NotificationColor.None || (hideBold && color == NotificationColor.Bold)) && !knocked) { + if ((level === NotificationLevel.None || (hideBold && level == NotificationLevel.Activity)) && !knocked) { return <>; } - const hasUnreadCount = color >= NotificationColor.Grey && (!!count || !!symbol); + const hasUnreadCount = level >= NotificationLevel.Notification && (!!count || !!symbol); const isEmptyBadge = symbol === null && count === 0; @@ -58,7 +58,7 @@ export const StatelessNotificationBadge = forwardRef= NotificationColor.Red, + mx_NotificationBadge_highlighted: level >= NotificationLevel.Highlight, mx_NotificationBadge_dot: isEmptyBadge && !knocked, mx_NotificationBadge_knocked: knocked, mx_NotificationBadge_2char: symbol && symbol.length > 0 && symbol.length < 3, diff --git a/src/components/views/rooms/NotificationBadge/UnreadNotificationBadge.tsx b/src/components/views/rooms/NotificationBadge/UnreadNotificationBadge.tsx index a937c181cc7..4708c33b95a 100644 --- a/src/components/views/rooms/NotificationBadge/UnreadNotificationBadge.tsx +++ b/src/components/views/rooms/NotificationBadge/UnreadNotificationBadge.tsx @@ -26,7 +26,7 @@ interface Props { } export function UnreadNotificationBadge({ room, threadId }: Props): JSX.Element { - const { symbol, count, color } = useUnreadNotifications(room, threadId); + const { symbol, count, level } = useUnreadNotifications(room, threadId); - return ; + return ; } diff --git a/src/components/views/rooms/RoomHeader.tsx b/src/components/views/rooms/RoomHeader.tsx index f770856203f..ec95e2a15c8 100644 --- a/src/components/views/rooms/RoomHeader.tsx +++ b/src/components/views/rooms/RoomHeader.tsx @@ -37,7 +37,7 @@ import { Flex } from "../../utils/Flex"; import { Box } from "../../utils/Box"; import { useRoomCall } from "../../../hooks/room/useRoomCall"; import { useRoomThreadNotifications } from "../../../hooks/room/useRoomThreadNotifications"; -import { NotificationColor } from "../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../stores/notifications/NotificationLevel"; import { useGlobalNotificationState } from "../../../hooks/useGlobalNotificationState"; import SdkConfig from "../../../SdkConfig"; import { useFeatureEnabled } from "../../../hooks/useSettings"; @@ -57,10 +57,10 @@ import { RoomKnocksBar } from "./RoomKnocksBar"; * A helper to transform a notification color to the what the Compound Icon Button * expects */ -function notificationColorToIndicator(color: NotificationColor): React.ComponentProps["indicator"] { - if (color <= NotificationColor.None) { +function notificationLevelToIndicator(color: NotificationLevel): React.ComponentProps["indicator"] { + if (color <= NotificationLevel.None) { return undefined; - } else if (color <= NotificationColor.Grey) { + } else if (color <= NotificationLevel.Notification) { return "default"; } else { return "highlight"; @@ -230,7 +230,7 @@ export default function RoomHeader({ { evt.stopPropagation(); RightPanelStore.instance.showOrHidePanel(RightPanelPhases.ThreadPanel); @@ -244,7 +244,7 @@ export default function RoomHeader({ {notificationsEnabled && ( { evt.stopPropagation(); RightPanelStore.instance.showOrHidePanel(RightPanelPhases.NotificationPanel); diff --git a/src/components/views/rooms/RoomHeader/VideoRoomChatButton.tsx b/src/components/views/rooms/RoomHeader/VideoRoomChatButton.tsx index ef8766a2b6b..de03ab88f27 100644 --- a/src/components/views/rooms/RoomHeader/VideoRoomChatButton.tsx +++ b/src/components/views/rooms/RoomHeader/VideoRoomChatButton.tsx @@ -23,7 +23,7 @@ import { isVideoRoom as calcIsVideoRoom } from "../../../../utils/video-rooms"; import { _t } from "../../../../languageHandler"; import { useEventEmitterState } from "../../../../hooks/useEventEmitter"; import { NotificationStateEvents } from "../../../../stores/notifications/NotificationState"; -import { NotificationColor } from "../../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../stores/notifications/NotificationLevel"; import { RightPanelPhases } from "../../../../stores/right-panel/RightPanelStorePhases"; import { SDKContext } from "../../../../contexts/SDKContext"; import { ButtonEvent } from "../../elements/AccessibleButton"; @@ -43,7 +43,7 @@ export const VideoRoomChatButton: React.FC<{ room: Room }> = ({ room }) => { const notificationColor = useEventEmitterState( notificationState, NotificationStateEvents.Update, - () => notificationState?.color, + () => notificationState?.level, ); if (!isVideoRoom) { @@ -52,7 +52,9 @@ export const VideoRoomChatButton: React.FC<{ room: Room }> = ({ room }) => { const displayUnreadIndicator = !!notificationColor && - [NotificationColor.Bold, NotificationColor.Grey, NotificationColor.Red].includes(notificationColor); + [NotificationLevel.Activity, NotificationLevel.Notification, NotificationLevel.Highlight].includes( + notificationColor, + ); const onClick = (event: ButtonEvent): void => { // stop event propagating up and triggering RoomHeader bar click diff --git a/src/components/views/rooms/RoomSublist.tsx b/src/components/views/rooms/RoomSublist.tsx index 6192f966e34..4e84bee0be2 100644 --- a/src/components/views/rooms/RoomSublist.tsx +++ b/src/components/views/rooms/RoomSublist.tsx @@ -421,7 +421,7 @@ export default class RoomSublist extends React.Component { // find the first room with a count of the same colour as the badge count room = RoomListStore.instance.orderedLists[this.props.tagId].find((r: Room) => { const notifState = this.notificationState.getForRoom(r); - return notifState.count > 0 && notifState.color === this.notificationState.color; + return notifState.count > 0 && notifState.level === this.notificationState.level; }); } diff --git a/src/components/views/rooms/VoiceRecordComposerTile.tsx b/src/components/views/rooms/VoiceRecordComposerTile.tsx index 5cc469a2958..70cabb474c9 100644 --- a/src/components/views/rooms/VoiceRecordComposerTile.tsx +++ b/src/components/views/rooms/VoiceRecordComposerTile.tsx @@ -33,7 +33,7 @@ import ErrorDialog from "../dialogs/ErrorDialog"; import MediaDeviceHandler, { MediaDeviceKindEnum } from "../../../MediaDeviceHandler"; import NotificationBadge from "./NotificationBadge"; import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState"; -import { NotificationColor } from "../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../stores/notifications/NotificationLevel"; import InlineSpinner from "../elements/InlineSpinner"; import { PlaybackManager } from "../../../audio/PlaybackManager"; import { doMaybeLocalRoomAction } from "../../../utils/local-room"; @@ -305,7 +305,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent {/* Need to stick the badge in a span to ensure it doesn't create a block component */} {_t("timeline|send_state_failed")} diff --git a/src/components/views/settings/notifications/NotificationSettings2.tsx b/src/components/views/settings/notifications/NotificationSettings2.tsx index 752532ebd20..bdc021e486e 100644 --- a/src/components/views/settings/notifications/NotificationSettings2.tsx +++ b/src/components/views/settings/notifications/NotificationSettings2.tsx @@ -28,7 +28,7 @@ import { import { RoomNotifState } from "../../../../RoomNotifs"; import { SettingLevel } from "../../../../settings/SettingLevel"; import SettingsStore from "../../../../settings/SettingsStore"; -import { NotificationColor } from "../../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../stores/notifications/NotificationLevel"; import { clearAllNotifications } from "../../../../utils/notifications"; import AccessibleButton from "../../elements/AccessibleButton"; import ExternalLink from "../../elements/ExternalLink"; @@ -278,7 +278,13 @@ export default function NotificationSettings2(): JSX.Element { "settings|notifications|keywords", {}, { - badge: , + badge: ( + + ), }, )} > diff --git a/src/components/views/spaces/SpaceTreeLevel.tsx b/src/components/views/spaces/SpaceTreeLevel.tsx index 401f9c2778f..c0b71709238 100644 --- a/src/components/views/spaces/SpaceTreeLevel.tsx +++ b/src/components/views/spaces/SpaceTreeLevel.tsx @@ -40,7 +40,7 @@ import { toRightOf, useContextMenu } from "../../structures/ContextMenu"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton"; import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState"; -import { NotificationColor } from "../../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../stores/notifications/NotificationLevel"; import { getKeyBindingsManager } from "../../../KeyBindingsManager"; import { NotificationState } from "../../../stores/notifications/NotificationState"; import SpaceContextMenu from "../context_menus/SpaceContextMenu"; @@ -329,7 +329,7 @@ export class SpaceItem extends React.PureComponent { const isInvite = space.getMyMembership() === "invite"; const notificationState = isInvite - ? StaticNotificationState.forSymbol("!", NotificationColor.Red) + ? StaticNotificationState.forSymbol("!", NotificationLevel.Highlight) : SpaceStore.instance.getNotificationState(space.roomId); const hasChildren = this.state.childSpaces?.length; diff --git a/src/hooks/room/useRoomThreadNotifications.ts b/src/hooks/room/useRoomThreadNotifications.ts index 10dcdad5138..93c3b8eed0e 100644 --- a/src/hooks/room/useRoomThreadNotifications.ts +++ b/src/hooks/room/useRoomThreadNotifications.ts @@ -17,7 +17,7 @@ limitations under the License. import { NotificationCountType, Room, RoomEvent, ThreadEvent } from "matrix-js-sdk/src/matrix"; import { useCallback, useEffect, useState } from "react"; -import { NotificationColor } from "../../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../stores/notifications/NotificationLevel"; import { doesRoomOrThreadHaveUnreadMessages } from "../../Unread"; import { useEventEmitter } from "../useEventEmitter"; @@ -26,16 +26,16 @@ import { useEventEmitter } from "../useEventEmitter"; * @param room the room to track * @returns the type of notification for this room */ -export const useRoomThreadNotifications = (room: Room): NotificationColor => { - const [notificationColor, setNotificationColor] = useState(NotificationColor.None); +export const useRoomThreadNotifications = (room: Room): NotificationLevel => { + const [notificationLevel, setNotificationLevel] = useState(NotificationLevel.None); const updateNotification = useCallback(() => { switch (room?.threadsAggregateNotificationType) { case NotificationCountType.Highlight: - setNotificationColor(NotificationColor.Red); + setNotificationLevel(NotificationLevel.Highlight); break; case NotificationCountType.Total: - setNotificationColor(NotificationColor.Grey); + setNotificationLevel(NotificationLevel.Notification); break; } // We don't have any notified messages, but we might have unread messages. Let's @@ -43,7 +43,7 @@ export const useRoomThreadNotifications = (room: Room): NotificationColor => { for (const thread of room!.getThreads()) { // If the current thread has unread messages, we're done. if (doesRoomOrThreadHaveUnreadMessages(thread)) { - setNotificationColor(NotificationColor.Bold); + setNotificationLevel(NotificationLevel.Activity); break; } } @@ -63,5 +63,5 @@ export const useRoomThreadNotifications = (room: Room): NotificationColor => { updateNotification(); }, [updateNotification]); - return notificationColor; + return notificationLevel; }; diff --git a/src/hooks/useUnreadNotifications.ts b/src/hooks/useUnreadNotifications.ts index 791c1c4bc96..fd4bab9edfe 100644 --- a/src/hooks/useUnreadNotifications.ts +++ b/src/hooks/useUnreadNotifications.ts @@ -19,7 +19,7 @@ import { useCallback, useEffect, useState } from "react"; import type { NotificationCount, Room } from "matrix-js-sdk/src/matrix"; import { determineUnreadState } from "../RoomNotifs"; -import { NotificationColor } from "../stores/notifications/NotificationColor"; +import { NotificationLevel } from "../stores/notifications/NotificationLevel"; import { useEventEmitter } from "./useEventEmitter"; export const useUnreadNotifications = ( @@ -28,11 +28,11 @@ export const useUnreadNotifications = ( ): { symbol: string | null; count: number; - color: NotificationColor; + level: NotificationLevel; } => { const [symbol, setSymbol] = useState(null); const [count, setCount] = useState(0); - const [color, setColor] = useState(NotificationColor.None); + const [level, setLevel] = useState(NotificationLevel.None); useEventEmitter( room, @@ -50,10 +50,10 @@ export const useUnreadNotifications = ( useEventEmitter(room, RoomEvent.MyMembership, () => updateNotificationState()); const updateNotificationState = useCallback(() => { - const { symbol, count, color } = determineUnreadState(room, threadId); + const { symbol, count, level } = determineUnreadState(room, threadId); setSymbol(symbol); setCount(count); - setColor(color); + setLevel(level); }, [room, threadId]); useEffect(() => { @@ -63,6 +63,6 @@ export const useUnreadNotifications = ( return { symbol, count, - color, + level, }; }; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index cc1cd4d79bb..40310cc8ac8 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1603,12 +1603,6 @@ "all_messages_description": "Get notified for every message", "class_global": "Global", "class_other": "Other", - "colour_bold": "Bold", - "colour_grey": "Grey", - "colour_muted": "Muted", - "colour_none": "None", - "colour_red": "Red", - "colour_unsent": "Unsent", "default": "Default", "email_pusher_app_display_name": "Email Notifications", "enable_prompt_toast_description": "Enable desktop notifications", @@ -1617,6 +1611,12 @@ "error_change_title": "Change notification settings", "keyword": "Keyword", "keyword_new": "New keyword", + "level_activity": "Activity", + "level_highlight": "Highlight", + "level_muted": "Muted", + "level_none": "None", + "level_notification": "Notification", + "level_unsent": "Unsent", "mark_all_read": "Mark all as read", "mentions_and_keywords": "@mentions & keywords", "mentions_and_keywords_description": "Get notified only with mentions and keywords as set up in your settings", diff --git a/src/stores/notifications/ListNotificationState.ts b/src/stores/notifications/ListNotificationState.ts index 7d246786201..04dbf6ed8df 100644 --- a/src/stores/notifications/ListNotificationState.ts +++ b/src/stores/notifications/ListNotificationState.ts @@ -16,7 +16,7 @@ limitations under the License. import { Room } from "matrix-js-sdk/src/matrix"; -import { NotificationColor } from "./NotificationColor"; +import { NotificationLevel } from "./NotificationLevel"; import { arrayDiff } from "../../utils/arrays"; import { RoomNotificationState } from "./RoomNotificationState"; import { NotificationState, NotificationStateEvents } from "./NotificationState"; @@ -35,7 +35,7 @@ export class ListNotificationState extends NotificationState { } public get symbol(): string | null { - return this._color === NotificationColor.Unsent ? "!" : null; + return this._level === NotificationLevel.Unsent ? "!" : null; } public setRooms(rooms: Room[]): void { @@ -86,14 +86,14 @@ export class ListNotificationState extends NotificationState { const snapshot = this.snapshot(); if (this.byTileCount) { - this._color = NotificationColor.Red; + this._level = NotificationLevel.Highlight; this._count = this.rooms.length; } else { this._count = 0; - this._color = NotificationColor.None; + this._level = NotificationLevel.None; for (const state of Object.values(this.states)) { this._count += state.count; - this._color = Math.max(this.color, state.color); + this._level = Math.max(this.level, state.level); } } diff --git a/src/stores/notifications/NotificationColor.ts b/src/stores/notifications/NotificationLevel.ts similarity index 51% rename from src/stores/notifications/NotificationColor.ts rename to src/stores/notifications/NotificationLevel.ts index f43bf27ccf8..1d1e5843bf3 100644 --- a/src/stores/notifications/NotificationColor.ts +++ b/src/stores/notifications/NotificationLevel.ts @@ -16,30 +16,30 @@ limitations under the License. import { _t } from "../../languageHandler"; -export enum NotificationColor { +export enum NotificationLevel { Muted, // Inverted (None -> Red) because we do integer comparisons on this None, // nothing special // TODO: Remove bold with notifications: https://github.com/vector-im/element-web/issues/14227 - Bold, // no badge, show as unread - Grey, // unread notified messages - Red, // unread pings + Activity, // no badge, show as unread + Notification, // unread notified messages + Highlight, // unread pings Unsent, // some messages failed to send } -export function humanReadableNotificationColor(color: NotificationColor): string { - switch (color) { - case NotificationColor.None: - return _t("notifications|colour_none"); - case NotificationColor.Bold: - return _t("notifications|colour_bold"); - case NotificationColor.Grey: - return _t("notifications|colour_grey"); - case NotificationColor.Red: - return _t("notifications|colour_red"); - case NotificationColor.Unsent: - return _t("notifications|colour_unsent"); - case NotificationColor.Muted: - return _t("notifications|colour_muted"); +export function humanReadableNotificationLevel(level: NotificationLevel): string { + switch (level) { + case NotificationLevel.None: + return _t("notifications|level_none"); + case NotificationLevel.Activity: + return _t("notifications|level_activity"); + case NotificationLevel.Notification: + return _t("notifications|level_notification"); + case NotificationLevel.Highlight: + return _t("notifications|level_highlight"); + case NotificationLevel.Unsent: + return _t("notifications|level_unsent"); + case NotificationLevel.Muted: + return _t("notifications|level_muted"); } } diff --git a/src/stores/notifications/NotificationState.ts b/src/stores/notifications/NotificationState.ts index 6de2d6b853d..79c0409e3e5 100644 --- a/src/stores/notifications/NotificationState.ts +++ b/src/stores/notifications/NotificationState.ts @@ -16,14 +16,14 @@ limitations under the License. import { TypedEventEmitter } from "matrix-js-sdk/src/matrix"; -import { NotificationColor } from "./NotificationColor"; +import { NotificationLevel } from "./NotificationLevel"; import { IDestroyable } from "../../utils/IDestroyable"; import SettingsStore from "../../settings/SettingsStore"; export interface INotificationStateSnapshotParams { symbol: string | null; count: number; - color: NotificationColor; + level: NotificationLevel; muted: boolean; knocked: boolean; } @@ -43,7 +43,7 @@ export abstract class NotificationState // protected _symbol: string | null = null; protected _count = 0; - protected _color: NotificationColor = NotificationColor.None; + protected _level: NotificationLevel = NotificationLevel.None; protected _muted = false; protected _knocked = false; @@ -66,8 +66,8 @@ export abstract class NotificationState return this._count; } - public get color(): NotificationColor { - return this._color; + public get level(): NotificationLevel { + return this._level; } public get muted(): boolean { @@ -79,24 +79,24 @@ export abstract class NotificationState } public get isIdle(): boolean { - return this.color <= NotificationColor.None; + return this.level <= NotificationLevel.None; } public get isUnread(): boolean { - if (this.color > NotificationColor.Bold) { + if (this.level > NotificationLevel.Activity) { return true; } else { const hideBold = SettingsStore.getValue("feature_hidebold"); - return this.color === NotificationColor.Bold && !hideBold; + return this.level === NotificationLevel.Activity && !hideBold; } } public get hasUnreadCount(): boolean { - return this.color >= NotificationColor.Grey && (!!this.count || !!this.symbol); + return this.level >= NotificationLevel.Notification && (!!this.count || !!this.symbol); } public get hasMentions(): boolean { - return this.color >= NotificationColor.Red; + return this.level >= NotificationLevel.Highlight; } protected emitIfUpdated(snapshot: NotificationStateSnapshot): void { @@ -121,14 +121,14 @@ export abstract class NotificationState export class NotificationStateSnapshot { private readonly symbol: string | null; private readonly count: number; - private readonly color: NotificationColor; + private readonly level: NotificationLevel; private readonly muted: boolean; private readonly knocked: boolean; public constructor(state: INotificationStateSnapshotParams) { this.symbol = state.symbol; this.count = state.count; - this.color = state.color; + this.level = state.level; this.muted = state.muted; this.knocked = state.knocked; } @@ -137,14 +137,14 @@ export class NotificationStateSnapshot { const before = { count: this.count, symbol: this.symbol, - color: this.color, + level: this.level, muted: this.muted, knocked: this.knocked, }; const after = { count: other.count, symbol: other.symbol, - color: other.color, + level: other.level, muted: other.muted, knocked: other.knocked, }; diff --git a/src/stores/notifications/RoomNotificationState.ts b/src/stores/notifications/RoomNotificationState.ts index 44b4931f909..be5d5918342 100644 --- a/src/stores/notifications/RoomNotificationState.ts +++ b/src/stores/notifications/RoomNotificationState.ts @@ -90,11 +90,11 @@ export class RoomNotificationState extends NotificationState implements IDestroy private updateNotificationState(): void { const snapshot = this.snapshot(); - const { color, symbol, count } = RoomNotifs.determineUnreadState(this.room); + const { level, symbol, count } = RoomNotifs.determineUnreadState(this.room); const muted = RoomNotifs.getRoomNotifsState(this.room.client, this.room.roomId) === RoomNotifs.RoomNotifState.Mute; const knocked = SettingsStore.getValue("feature_ask_to_join") && this.room.getMyMembership() === "knock"; - this._color = color; + this._level = level; this._symbol = symbol; this._count = count; this._muted = muted; diff --git a/src/stores/notifications/RoomNotificationStateStore.ts b/src/stores/notifications/RoomNotificationStateStore.ts index ce9b89871ca..5c8161a3383 100644 --- a/src/stores/notifications/RoomNotificationStateStore.ts +++ b/src/stores/notifications/RoomNotificationStateStore.ts @@ -138,7 +138,7 @@ export class RoomNotificationStateStore extends AsyncStoreWithClient { if ( this.globalState.symbol !== globalState.symbol || this.globalState.count !== globalState.count || - this.globalState.color !== globalState.color || + this.globalState.level !== globalState.level || this.globalState.numUnreadStates !== globalState.numUnreadStates || forceEmit ) { diff --git a/src/stores/notifications/SpaceNotificationState.ts b/src/stores/notifications/SpaceNotificationState.ts index 7c9bfa2e96c..e5054bf5944 100644 --- a/src/stores/notifications/SpaceNotificationState.ts +++ b/src/stores/notifications/SpaceNotificationState.ts @@ -16,7 +16,7 @@ limitations under the License. import { Room } from "matrix-js-sdk/src/matrix"; -import { NotificationColor } from "./NotificationColor"; +import { NotificationLevel } from "./NotificationLevel"; import { arrayDiff } from "../../utils/arrays"; import { RoomNotificationState } from "./RoomNotificationState"; import { NotificationState, NotificationStateEvents } from "./NotificationState"; @@ -33,7 +33,7 @@ export class SpaceNotificationState extends NotificationState { } public get symbol(): string | null { - return this._color === NotificationColor.Unsent ? "!" : null; + return this._level === NotificationLevel.Unsent ? "!" : null; } public setRooms(rooms: Room[]): void { @@ -56,7 +56,7 @@ export class SpaceNotificationState extends NotificationState { } public getFirstRoomWithNotifications(): string | undefined { - return Object.values(this.states).find((state) => state.color >= this.color)?.room.roomId; + return Object.values(this.states).find((state) => state.level >= this.level)?.room.roomId; } public destroy(): void { @@ -75,16 +75,16 @@ export class SpaceNotificationState extends NotificationState { const snapshot = this.snapshot(); this._count = 0; - this._color = NotificationColor.None; + this._level = NotificationLevel.None; for (const [roomId, state] of Object.entries(this.states)) { const room = this.rooms.find((r) => r.roomId === roomId); const roomTags = room ? RoomListStore.instance.getTagsForRoom(room) : []; // We ignore unreads in LowPriority rooms, see https://github.com/vector-im/element-web/issues/16836 - if (roomTags.includes(DefaultTagID.LowPriority) && state.color === NotificationColor.Bold) continue; + if (roomTags.includes(DefaultTagID.LowPriority) && state.level === NotificationLevel.Activity) continue; this._count += state.count; - this._color = Math.max(this.color, state.color); + this._level = Math.max(this.level, state.level); } // finally, publish an update if needed diff --git a/src/stores/notifications/StaticNotificationState.ts b/src/stores/notifications/StaticNotificationState.ts index 2b992213137..7ad33cbd4e4 100644 --- a/src/stores/notifications/StaticNotificationState.ts +++ b/src/stores/notifications/StaticNotificationState.ts @@ -14,24 +14,24 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { NotificationColor } from "./NotificationColor"; +import { NotificationLevel } from "./NotificationLevel"; import { NotificationState } from "./NotificationState"; export class StaticNotificationState extends NotificationState { - public static readonly RED_EXCLAMATION = StaticNotificationState.forSymbol("!", NotificationColor.Red); + public static readonly RED_EXCLAMATION = StaticNotificationState.forSymbol("!", NotificationLevel.Highlight); - public constructor(symbol: string | null, count: number, color: NotificationColor) { + public constructor(symbol: string | null, count: number, level: NotificationLevel) { super(); this._symbol = symbol; this._count = count; - this._color = color; + this._level = level; } - public static forCount(count: number, color: NotificationColor): StaticNotificationState { - return new StaticNotificationState(null, count, color); + public static forCount(count: number, level: NotificationLevel): StaticNotificationState { + return new StaticNotificationState(null, count, level); } - public static forSymbol(symbol: string, color: NotificationColor): StaticNotificationState { - return new StaticNotificationState(symbol, 0, color); + public static forSymbol(symbol: string, level: NotificationLevel): StaticNotificationState { + return new StaticNotificationState(symbol, 0, level); } } diff --git a/src/stores/notifications/SummarizedNotificationState.ts b/src/stores/notifications/SummarizedNotificationState.ts index 1d459ac2eaf..d0317672826 100644 --- a/src/stores/notifications/SummarizedNotificationState.ts +++ b/src/stores/notifications/SummarizedNotificationState.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { NotificationColor } from "./NotificationColor"; +import { NotificationLevel } from "./NotificationLevel"; import { NotificationState } from "./NotificationState"; /** @@ -30,7 +30,7 @@ export class SummarizedNotificationState extends NotificationState { super(); this._symbol = null; this._count = 0; - this._color = NotificationColor.None; + this._level = NotificationLevel.None; } public get numUnreadStates(): number { @@ -52,8 +52,8 @@ export class SummarizedNotificationState extends NotificationState { if (other.count) { this._count += other.count; } - if (other.color > this.color) { - this._color = other.color; + if (other.level > this.level) { + this._level = other.level; } if (other.hasUnreadCount) { this.totalStatesWithUnread++; diff --git a/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts b/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts index 12548c5d20f..09cb1d16d90 100644 --- a/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts +++ b/src/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm.ts @@ -22,27 +22,27 @@ import { RoomUpdateCause, TagID } from "../../models"; import { SortAlgorithm } from "../models"; import { sortRoomsWithAlgorithm } from "../tag-sorting"; import { OrderingAlgorithm } from "./OrderingAlgorithm"; -import { NotificationColor } from "../../../notifications/NotificationColor"; +import { NotificationLevel } from "../../../notifications/NotificationLevel"; import { RoomNotificationStateStore } from "../../../notifications/RoomNotificationStateStore"; type CategorizedRoomMap = { - [category in NotificationColor]: Room[]; + [category in NotificationLevel]: Room[]; }; type CategoryIndex = Partial<{ - [category in NotificationColor]: number; // integer + [category in NotificationLevel]: number; // integer }>; // Caution: changing this means you'll need to update a bunch of assumptions and // comments! Check the usage of Category carefully to figure out what needs changing // if you're going to change this array's order. const CATEGORY_ORDER = [ - NotificationColor.Unsent, - NotificationColor.Red, - NotificationColor.Grey, - NotificationColor.Bold, - NotificationColor.None, // idle - NotificationColor.Muted, + NotificationLevel.Unsent, + NotificationLevel.Highlight, + NotificationLevel.Notification, + NotificationLevel.Activity, + NotificationLevel.None, // idle + NotificationLevel.Muted, ]; /** @@ -77,12 +77,12 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { // noinspection JSMethodCanBeStatic private categorizeRooms(rooms: Room[]): CategorizedRoomMap { const map: CategorizedRoomMap = { - [NotificationColor.Unsent]: [], - [NotificationColor.Red]: [], - [NotificationColor.Grey]: [], - [NotificationColor.Bold]: [], - [NotificationColor.None]: [], - [NotificationColor.Muted]: [], + [NotificationLevel.Unsent]: [], + [NotificationLevel.Highlight]: [], + [NotificationLevel.Notification]: [], + [NotificationLevel.Activity]: [], + [NotificationLevel.None]: [], + [NotificationLevel.Muted]: [], }; for (const room of rooms) { const category = this.getRoomCategory(room); @@ -92,11 +92,11 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { } // noinspection JSMethodCanBeStatic - private getRoomCategory(room: Room): NotificationColor { + private getRoomCategory(room: Room): NotificationLevel { // It's fine for us to call this a lot because it's cached, and we shouldn't be // wasting anything by doing so as the store holds single references const state = RoomNotificationStateStore.instance.getRoomState(room); - return this.isMutedToBottom && state.muted ? NotificationColor.Muted : state.color; + return this.isMutedToBottom && state.muted ? NotificationLevel.Muted : state.level; } public setRooms(rooms: Room[]): void { @@ -106,7 +106,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { // Every other sorting type affects the categories, not the whole tag. const categorized = this.categorizeRooms(rooms); for (const category of Object.keys(categorized)) { - const notificationColor = category as unknown as NotificationColor; + const notificationColor = category as unknown as NotificationLevel; const roomsToOrder = categorized[notificationColor]; categorized[notificationColor] = sortRoomsWithAlgorithm( roomsToOrder, @@ -128,7 +128,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { } } - private getCategoryIndex(category: NotificationColor): number { + private getCategoryIndex(category: NotificationLevel): number { const categoryIndex = this.indices[category]; if (categoryIndex === undefined) { @@ -213,7 +213,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { return true; // change made } - private sortCategory(category: NotificationColor): void { + private sortCategory(category: NotificationLevel): void { // This should be relatively quick because the room is usually inserted at the top of the // category, and most popular sorting algorithms will deal with trying to keep the active // room at the top/start of the category. For the few algorithms that will have to move the @@ -231,7 +231,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { } // noinspection JSMethodCanBeStatic - private getCategoryFromIndices(index: number, indices: CategoryIndex): NotificationColor { + private getCategoryFromIndices(index: number, indices: CategoryIndex): NotificationLevel { for (let i = 0; i < CATEGORY_ORDER.length; i++) { const category = CATEGORY_ORDER[i]; const isLast = i === CATEGORY_ORDER.length - 1; @@ -252,8 +252,8 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { // noinspection JSMethodCanBeStatic private moveRoomIndexes( nRooms: number, - fromCategory: NotificationColor, - toCategory: NotificationColor, + fromCategory: NotificationLevel, + toCategory: NotificationLevel, indices: CategoryIndex, ): void { // We have to update the index of the category *after* the from/toCategory variables @@ -266,7 +266,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm { this.alterCategoryPositionBy(toCategory, +nRooms, indices); } - private alterCategoryPositionBy(category: NotificationColor, n: number, indices: CategoryIndex): void { + private alterCategoryPositionBy(category: NotificationLevel, n: number, indices: CategoryIndex): void { // Note: when we alter a category's index, we actually have to modify the ones following // the target and not the target itself. diff --git a/test/RoomNotifs-test.ts b/test/RoomNotifs-test.ts index 3544e862c24..f558ccc68ae 100644 --- a/test/RoomNotifs-test.ts +++ b/test/RoomNotifs-test.ts @@ -34,7 +34,7 @@ import { getUnreadNotificationCount, determineUnreadState, } from "../src/RoomNotifs"; -import { NotificationColor } from "../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../src/stores/notifications/NotificationLevel"; import SettingsStore from "../src/settings/SettingsStore"; import { MatrixClientPeg } from "../src/MatrixClientPeg"; @@ -252,10 +252,10 @@ describe("RoomNotifs test", () => { }); it("shows nothing by default", async () => { - const { color, symbol, count } = determineUnreadState(room); + const { level, symbol, count } = determineUnreadState(room); expect(symbol).toBe(null); - expect(color).toBe(NotificationColor.None); + expect(level).toBe(NotificationLevel.None); expect(count).toBe(0); }); @@ -269,20 +269,20 @@ describe("RoomNotifs test", () => { event.status = EventStatus.NOT_SENT; room.addPendingEvent(event, "txn"); - const { color, symbol, count } = determineUnreadState(room); + const { level, symbol, count } = determineUnreadState(room); expect(symbol).toBe("!"); - expect(color).toBe(NotificationColor.Unsent); + expect(level).toBe(NotificationLevel.Unsent); expect(count).toBeGreaterThan(0); }); it("indicates the user has been invited to a channel", async () => { room.updateMyMembership("invite"); - const { color, symbol, count } = determineUnreadState(room); + const { level, symbol, count } = determineUnreadState(room); expect(symbol).toBe("!"); - expect(color).toBe(NotificationColor.Red); + expect(level).toBe(NotificationLevel.Highlight); expect(count).toBeGreaterThan(0); }); @@ -294,10 +294,10 @@ describe("RoomNotifs test", () => { membership: "knock", }); jest.spyOn(room, "getMember").mockReturnValue(roomMember); - const { color, symbol, count } = determineUnreadState(room); + const { level, symbol, count } = determineUnreadState(room); expect(symbol).toBe("!"); - expect(color).toBe(NotificationColor.Red); + expect(level).toBe(NotificationLevel.Highlight); expect(count).toBeGreaterThan(0); }); @@ -306,27 +306,27 @@ describe("RoomNotifs test", () => { room.setUnreadNotificationCount(NotificationCountType.Total, 99); muteRoom(room); - const { color, count } = determineUnreadState(room); + const { level, count } = determineUnreadState(room); - expect(color).toBe(NotificationColor.None); + expect(level).toBe(NotificationLevel.None); expect(count).toBe(0); }); it("uses the correct number of unreads", async () => { room.setUnreadNotificationCount(NotificationCountType.Total, 999); - const { color, count } = determineUnreadState(room); + const { level, count } = determineUnreadState(room); - expect(color).toBe(NotificationColor.Grey); + expect(level).toBe(NotificationLevel.Notification); expect(count).toBe(999); }); it("uses the correct number of highlights", async () => { room.setUnreadNotificationCount(NotificationCountType.Highlight, 888); - const { color, count } = determineUnreadState(room); + const { level, count } = determineUnreadState(room); - expect(color).toBe(NotificationColor.Red); + expect(level).toBe(NotificationLevel.Highlight); expect(count).toBe(888); }); }); diff --git a/test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx b/test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx index ab02e6b9c4e..ef429562177 100644 --- a/test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx +++ b/test/components/views/right_panel/LegacyRoomHeaderButtons-test.tsx @@ -56,7 +56,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () { return container.querySelector(".mx_RightPanel_threadsButton"); } - function isIndicatorOfType(container: HTMLElement, type: "red" | "gray" | "bold") { + function isIndicatorOfType(container: HTMLElement, type: "highlight" | "notification" | "activity") { return container.querySelector(".mx_RightPanel_threadsButton .mx_Indicator")!.className.includes(type); } @@ -85,10 +85,10 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () { room.setThreadUnreadNotificationCount("$123", NotificationCountType.Total, 1); expect(getThreadButton(container)!.className.includes("mx_LegacyRoomHeader_button--unread")).toBeTruthy(); - expect(isIndicatorOfType(container, "gray")).toBe(true); + expect(isIndicatorOfType(container, "notification")).toBe(true); room.setThreadUnreadNotificationCount("$123", NotificationCountType.Highlight, 1); - expect(isIndicatorOfType(container, "red")).toBe(true); + expect(isIndicatorOfType(container, "highlight")).toBe(true); room.setThreadUnreadNotificationCount("$123", NotificationCountType.Total, 0); room.setThreadUnreadNotificationCount("$123", NotificationCountType.Highlight, 0); @@ -122,7 +122,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () { }, }); room.addReceipt(receipt); - expect(isIndicatorOfType(container, "bold")).toBe(true); + expect(isIndicatorOfType(container, "activity")).toBe(true); // Sending the last event should clear the notification. let event = mkEvent({ @@ -158,7 +158,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () { }, }); room.addLiveEvents([event]); - expect(isIndicatorOfType(container, "bold")).toBe(true); + expect(isIndicatorOfType(container, "activity")).toBe(true); // Sending a read receipt on an earlier event shouldn't do anything. receipt = new MatrixEvent({ @@ -173,7 +173,7 @@ describe("LegacyRoomHeaderButtons-test.tsx", function () { }, }); room.addReceipt(receipt); - expect(isIndicatorOfType(container, "bold")).toBe(true); + expect(isIndicatorOfType(container, "activity")).toBe(true); // Sending a receipt on the latest event should clear the notification. receipt = new MatrixEvent({ diff --git a/test/components/views/rooms/NotificationBadge/NotificationBadge-test.tsx b/test/components/views/rooms/NotificationBadge/NotificationBadge-test.tsx index e0aa0d89bdf..79cd3fcae03 100644 --- a/test/components/views/rooms/NotificationBadge/NotificationBadge-test.tsx +++ b/test/components/views/rooms/NotificationBadge/NotificationBadge-test.tsx @@ -19,7 +19,7 @@ import React from "react"; import { StatelessNotificationBadge } from "../../../../../src/components/views/rooms/NotificationBadge/StatelessNotificationBadge"; import SettingsStore from "../../../../../src/settings/SettingsStore"; -import { NotificationColor } from "../../../../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../../src/stores/notifications/NotificationLevel"; describe("NotificationBadge", () => { describe("StatelessNotificationBadge", () => { @@ -27,7 +27,7 @@ describe("NotificationBadge", () => { const cb = jest.fn(); const { getByRole } = render( - , + , ); fireEvent.click(getByRole("button")!); @@ -40,7 +40,7 @@ describe("NotificationBadge", () => { }); const { container } = render( - , + , ); expect(container.firstChild).toBeNull(); diff --git a/test/components/views/rooms/NotificationBadge/StatelessNotificationBadge-test.tsx b/test/components/views/rooms/NotificationBadge/StatelessNotificationBadge-test.tsx index c6d2b843e6e..a6f1cd66be1 100644 --- a/test/components/views/rooms/NotificationBadge/StatelessNotificationBadge-test.tsx +++ b/test/components/views/rooms/NotificationBadge/StatelessNotificationBadge-test.tsx @@ -18,19 +18,19 @@ import React from "react"; import { render } from "@testing-library/react"; import { StatelessNotificationBadge } from "../../../../../src/components/views/rooms/NotificationBadge/StatelessNotificationBadge"; -import { NotificationColor } from "../../../../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../../src/stores/notifications/NotificationLevel"; describe("StatelessNotificationBadge", () => { it("is highlighted when unsent", () => { const { container } = render( - , + , ); expect(container.querySelector(".mx_NotificationBadge_highlighted")).not.toBe(null); }); it("has knock style", () => { const { container } = render( - , + , ); expect(container.querySelector(".mx_NotificationBadge_dot")).not.toBeInTheDocument(); expect(container.querySelector(".mx_NotificationBadge_knocked")).toBeInTheDocument(); diff --git a/test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx b/test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx index b515a1f87ae..bc9eb10b560 100644 --- a/test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx +++ b/test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx @@ -25,7 +25,7 @@ import { SDKContext, SdkContextClass } from "../../../../../src/contexts/SDKCont import RightPanelStore from "../../../../../src/stores/right-panel/RightPanelStore"; import { getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../../test-utils"; import { RoomNotificationState } from "../../../../../src/stores/notifications/RoomNotificationState"; -import { NotificationColor } from "../../../../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../../src/stores/notifications/NotificationLevel"; import { NotificationStateEvents } from "../../../../../src/stores/notifications/NotificationState"; import { RightPanelPhases } from "../../../../../src/stores/right-panel/RightPanelStorePhases"; @@ -46,11 +46,11 @@ describe("", () => { return room; }; - const mockRoomNotificationState = (room: Room, color: NotificationColor): RoomNotificationState => { + const mockRoomNotificationState = (room: Room, level: NotificationLevel): RoomNotificationState => { const roomNotificationState = new RoomNotificationState(room); // @ts-ignore ugly mocking - roomNotificationState._color = color; + roomNotificationState._level = level; jest.spyOn(sdkContext.roomNotificationStateStore, "getRoomState").mockReturnValue(roomNotificationState); return roomNotificationState; }; @@ -105,7 +105,7 @@ describe("", () => { it("renders button with an unread marker when room is unread", () => { const room = makeRoom(); - mockRoomNotificationState(room, NotificationColor.Bold); + mockRoomNotificationState(room, NotificationLevel.Activity); getComponent(room); // snapshot includes `data-indicator` attribute @@ -116,14 +116,14 @@ describe("", () => { it("adds unread marker when room notification state changes to unread", () => { const room = makeRoom(); // start in read state - const notificationState = mockRoomNotificationState(room, NotificationColor.None); + const notificationState = mockRoomNotificationState(room, NotificationLevel.None); getComponent(room); // no unread marker expect(screen.getByLabelText("Chat").hasAttribute("data-indicator")).toBeFalsy(); // @ts-ignore ugly mocking - notificationState._color = NotificationColor.Red; + notificationState._level = NotificationLevel.Highlight; notificationState.emit(NotificationStateEvents.Update); // unread marker @@ -133,14 +133,14 @@ describe("", () => { it("clears unread marker when room notification state changes to read", () => { const room = makeRoom(); // start in unread state - const notificationState = mockRoomNotificationState(room, NotificationColor.Red); + const notificationState = mockRoomNotificationState(room, NotificationLevel.Highlight); getComponent(room); // unread marker expect(screen.getByLabelText("Chat").hasAttribute("data-indicator")).toBeTruthy(); // @ts-ignore ugly mocking - notificationState._color = NotificationColor.None; + notificationState._level = NotificationLevel.None; notificationState.emit(NotificationStateEvents.Update); // unread marker cleared diff --git a/test/components/views/spaces/SpaceTreeLevel-test.tsx b/test/components/views/spaces/SpaceTreeLevel-test.tsx index b067bb34bd4..8a13a3b4d27 100644 --- a/test/components/views/spaces/SpaceTreeLevel-test.tsx +++ b/test/components/views/spaces/SpaceTreeLevel-test.tsx @@ -26,7 +26,7 @@ import { SpaceButton } from "../../../../src/components/views/spaces/SpaceTreeLe import { MetaSpace, SpaceKey } from "../../../../src/stores/spaces"; import SpaceStore from "../../../../src/stores/spaces/SpaceStore"; import { StaticNotificationState } from "../../../../src/stores/notifications/StaticNotificationState"; -import { NotificationColor } from "../../../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../src/stores/notifications/NotificationLevel"; jest.mock("../../../../src/stores/spaces/SpaceStore", () => { // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -117,7 +117,7 @@ describe("SpaceButton", () => { }); it("should render notificationState if one is provided", () => { - const notificationState = new StaticNotificationState(null, 8, NotificationColor.Grey); + const notificationState = new StaticNotificationState(null, 8, NotificationLevel.Notification); const { container, asFragment } = render( { it("returns none if no thread in the room has notifications", async () => { const { result } = render(room); - expect(result.current).toBe(NotificationColor.None); + expect(result.current).toBe(NotificationLevel.None); }); it("returns red if a thread in the room has a highlight notification", async () => { room.setThreadUnreadNotificationCount("flooble", NotificationCountType.Highlight, 1); const { result } = render(room); - expect(result.current).toBe(NotificationColor.Red); + expect(result.current).toBe(NotificationLevel.Highlight); }); it("returns grey if a thread in the room has a normal notification", async () => { room.setThreadUnreadNotificationCount("flooble", NotificationCountType.Total, 1); const { result } = render(room); - expect(result.current).toBe(NotificationColor.Grey); + expect(result.current).toBe(NotificationLevel.Notification); }); it("returns bold if a thread in the room unread messages", async () => { @@ -68,6 +68,6 @@ describe("useRoomThreadNotifications", () => { const { result } = render(room); - expect(result.current).toBe(NotificationColor.Bold); + expect(result.current).toBe(NotificationLevel.Activity); }); }); diff --git a/test/hooks/useUnreadNotifications-test.ts b/test/hooks/useUnreadNotifications-test.ts index 0bfd83351cc..504dbfddb1c 100644 --- a/test/hooks/useUnreadNotifications-test.ts +++ b/test/hooks/useUnreadNotifications-test.ts @@ -19,7 +19,7 @@ import { EventStatus, NotificationCountType, PendingEventOrdering, Room } from " import type { MatrixClient } from "matrix-js-sdk/src/matrix"; import { useUnreadNotifications } from "../../src/hooks/useUnreadNotifications"; -import { NotificationColor } from "../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../src/stores/notifications/NotificationLevel"; import { mkEvent, muteRoom, stubClient } from "../test-utils"; describe("useUnreadNotifications", () => { @@ -40,10 +40,10 @@ describe("useUnreadNotifications", () => { it("shows nothing by default", async () => { const { result } = renderHook(() => useUnreadNotifications(room)); - const { color, symbol, count } = result.current; + const { level, symbol, count } = result.current; expect(symbol).toBe(null); - expect(color).toBe(NotificationColor.None); + expect(level).toBe(NotificationLevel.None); expect(count).toBe(0); }); @@ -58,10 +58,10 @@ describe("useUnreadNotifications", () => { room.addPendingEvent(event, "txn"); const { result } = renderHook(() => useUnreadNotifications(room)); - const { color, symbol, count } = result.current; + const { level, symbol, count } = result.current; expect(symbol).toBe("!"); - expect(color).toBe(NotificationColor.Unsent); + expect(level).toBe(NotificationLevel.Unsent); expect(count).toBeGreaterThan(0); }); @@ -69,10 +69,10 @@ describe("useUnreadNotifications", () => { room.updateMyMembership("invite"); const { result } = renderHook(() => useUnreadNotifications(room)); - const { color, symbol, count } = result.current; + const { level, symbol, count } = result.current; expect(symbol).toBe("!"); - expect(color).toBe(NotificationColor.Red); + expect(level).toBe(NotificationLevel.Highlight); expect(count).toBeGreaterThan(0); }); @@ -81,9 +81,9 @@ describe("useUnreadNotifications", () => { muteRoom(room); const { result } = renderHook(() => useUnreadNotifications(room)); - const { color, count } = result.current; + const { level, count } = result.current; - expect(color).toBe(NotificationColor.None); + expect(level).toBe(NotificationLevel.None); expect(count).toBe(0); }); @@ -91,9 +91,9 @@ describe("useUnreadNotifications", () => { setUnreads(999, 0); const { result } = renderHook(() => useUnreadNotifications(room)); - const { color, count } = result.current; + const { level, count } = result.current; - expect(color).toBe(NotificationColor.Grey); + expect(level).toBe(NotificationLevel.Notification); expect(count).toBe(999); }); @@ -101,9 +101,9 @@ describe("useUnreadNotifications", () => { setUnreads(0, 888); const { result } = renderHook(() => useUnreadNotifications(room)); - const { color, count } = result.current; + const { level, count } = result.current; - expect(color).toBe(NotificationColor.Red); + expect(level).toBe(NotificationLevel.Highlight); expect(count).toBe(888); }); }); diff --git a/test/stores/SpaceStore-test.ts b/test/stores/SpaceStore-test.ts index 166040a021e..f13174066d4 100644 --- a/test/stores/SpaceStore-test.ts +++ b/test/stores/SpaceStore-test.ts @@ -46,7 +46,7 @@ import { MatrixClientPeg } from "../../src/MatrixClientPeg"; import RoomListStore from "../../src/stores/room-list/RoomListStore"; import { DefaultTagID } from "../../src/stores/room-list/models"; import { RoomNotificationStateStore } from "../../src/stores/notifications/RoomNotificationStateStore"; -import { NotificationColor } from "../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../src/stores/notifications/NotificationLevel"; jest.useFakeTimers(); @@ -1467,7 +1467,7 @@ describe("SpaceStore", () => { const room = mkRoom(room1); const state = RoomNotificationStateStore.instance.getRoomState(room); // @ts-ignore - state._color = NotificationColor.Grey; + state._level = NotificationLevel.Notification; jest.spyOn(RoomListStore.instance, "orderedLists", "get").mockReturnValue({ [DefaultTagID.Untagged]: [room], }); diff --git a/test/stores/notifications/NotificationColor-test.ts b/test/stores/notifications/NotificationColor-test.ts index 1125c47bff8..73708d0a9b6 100644 --- a/test/stores/notifications/NotificationColor-test.ts +++ b/test/stores/notifications/NotificationColor-test.ts @@ -14,18 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { humanReadableNotificationColor, NotificationColor } from "../../../src/stores/notifications/NotificationColor"; +import { humanReadableNotificationLevel, NotificationLevel } from "../../../src/stores/notifications/NotificationLevel"; -describe("NotificationColor", () => { - describe("humanReadableNotificationColor", () => { +describe("NotificationLevel", () => { + describe("humanReadableNotificationLevel", () => { it.each([ - [NotificationColor.None, "None"], - [NotificationColor.Bold, "Bold"], - [NotificationColor.Grey, "Grey"], - [NotificationColor.Red, "Red"], - [NotificationColor.Unsent, "Unsent"], + [NotificationLevel.None, "None"], + [NotificationLevel.Activity, "Activity"], + [NotificationLevel.Notification, "Notification"], + [NotificationLevel.Highlight, "Highlight"], + [NotificationLevel.Unsent, "Unsent"], ])("correctly maps the output", (color, output) => { - expect(humanReadableNotificationColor(color)).toBe(output); + expect(humanReadableNotificationLevel(color)).toBe(output); }); }); }); diff --git a/test/stores/notifications/RoomNotificationState-test.ts b/test/stores/notifications/RoomNotificationState-test.ts index ad4e450330a..f556afb6dfc 100644 --- a/test/stores/notifications/RoomNotificationState-test.ts +++ b/test/stores/notifications/RoomNotificationState-test.ts @@ -28,7 +28,7 @@ import type { MatrixClient } from "matrix-js-sdk/src/matrix"; import { mkEvent, muteRoom, stubClient } from "../../test-utils"; import { RoomNotificationState } from "../../../src/stores/notifications/RoomNotificationState"; import { NotificationStateEvents } from "../../../src/stores/notifications/NotificationState"; -import { NotificationColor } from "../../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../src/stores/notifications/NotificationLevel"; import { createMessageEventContent } from "../../test-utils/events"; describe("RoomNotificationState", () => { @@ -109,7 +109,7 @@ describe("RoomNotificationState", () => { event.status = EventStatus.NOT_SENT; room.addPendingEvent(event, "txn"); - expect(roomNotifState.color).toBe(NotificationColor.Unsent); + expect(roomNotifState.level).toBe(NotificationLevel.Unsent); expect(roomNotifState.symbol).toBe("!"); expect(roomNotifState.count).toBeGreaterThan(0); }); @@ -121,7 +121,7 @@ describe("RoomNotificationState", () => { setUnreads(room, 1234, 0); room.updateMyMembership("join"); // emit - expect(roomNotifState.color).toBe(NotificationColor.None); + expect(roomNotifState.level).toBe(NotificationLevel.None); expect(roomNotifState.symbol).toBe(null); expect(roomNotifState.count).toBe(0); }); @@ -131,7 +131,7 @@ describe("RoomNotificationState", () => { room.updateMyMembership("invite"); // emit - expect(roomNotifState.color).toBe(NotificationColor.Red); + expect(roomNotifState.level).toBe(NotificationLevel.Highlight); expect(roomNotifState.symbol).toBe("!"); expect(roomNotifState.count).toBeGreaterThan(0); }); @@ -142,7 +142,7 @@ describe("RoomNotificationState", () => { setUnreads(room, 4321, 0); room.updateMyMembership("join"); // emit - expect(roomNotifState.color).toBe(NotificationColor.Grey); + expect(roomNotifState.level).toBe(NotificationLevel.Notification); expect(roomNotifState.symbol).toBe(null); expect(roomNotifState.count).toBe(4321); }); @@ -153,7 +153,7 @@ describe("RoomNotificationState", () => { setUnreads(room, 0, 69); room.updateMyMembership("join"); // emit - expect(roomNotifState.color).toBe(NotificationColor.Red); + expect(roomNotifState.level).toBe(NotificationLevel.Highlight); expect(roomNotifState.symbol).toBe(null); expect(roomNotifState.count).toBe(69); }); @@ -173,7 +173,7 @@ describe("RoomNotificationState", () => { addThread(room); room.updateMyMembership("join"); // emit - expect(roomNotifState.color).toBe(NotificationColor.Bold); + expect(roomNotifState.level).toBe(NotificationLevel.Activity); expect(roomNotifState.symbol).toBe(null); }); }); diff --git a/test/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm-test.ts b/test/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm-test.ts index 7ffc34d4eb9..9d7ffa44260 100644 --- a/test/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm-test.ts +++ b/test/stores/room-list/algorithms/list-ordering/ImportanceAlgorithm-test.ts @@ -22,7 +22,7 @@ import { ImportanceAlgorithm } from "../../../../../src/stores/room-list/algorit import { SortAlgorithm } from "../../../../../src/stores/room-list/algorithms/models"; import * as RoomNotifs from "../../../../../src/RoomNotifs"; import { DefaultTagID, RoomUpdateCause } from "../../../../../src/stores/room-list/models"; -import { NotificationColor } from "../../../../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../../src/stores/notifications/NotificationLevel"; import { AlphabeticAlgorithm } from "../../../../../src/stores/room-list/algorithms/tag-sorting/AlphabeticAlgorithm"; import { getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../../test-utils"; import { RecentAlgorithm } from "../../../../../src/stores/room-list/algorithms/tag-sorting/RecentAlgorithm"; @@ -75,16 +75,16 @@ describe("ImportanceAlgorithm", () => { }; const unreadStates: Record> = { - red: { symbol: null, count: 1, color: NotificationColor.Red }, - grey: { symbol: null, count: 1, color: NotificationColor.Grey }, - none: { symbol: null, count: 0, color: NotificationColor.None }, + red: { symbol: null, count: 1, level: NotificationLevel.Highlight }, + grey: { symbol: null, count: 1, level: NotificationLevel.Notification }, + none: { symbol: null, count: 0, level: NotificationLevel.None }, }; beforeEach(() => { jest.spyOn(RoomNotifs, "determineUnreadState").mockReturnValue({ symbol: null, count: 0, - color: NotificationColor.None, + level: NotificationLevel.None, }); }); @@ -190,7 +190,7 @@ describe("ImportanceAlgorithm", () => { jest.spyOn(RoomNotifs, "determineUnreadState").mockReturnValue({ symbol: null, count: 0, - color: NotificationColor.None, + level: NotificationLevel.None, }); const algorithm = setupAlgorithm(sortAlgorithm); @@ -360,7 +360,7 @@ describe("ImportanceAlgorithm", () => { jest.spyOn(RoomNotifs, "determineUnreadState").mockReturnValue({ symbol: null, count: 0, - color: NotificationColor.None, + level: NotificationLevel.None, }); const algorithm = setupAlgorithm(sortAlgorithm); diff --git a/test/stores/room-list/algorithms/list-ordering/NaturalAlgorithm-test.ts b/test/stores/room-list/algorithms/list-ordering/NaturalAlgorithm-test.ts index b9f7dd1b0db..7a26bf65caf 100644 --- a/test/stores/room-list/algorithms/list-ordering/NaturalAlgorithm-test.ts +++ b/test/stores/room-list/algorithms/list-ordering/NaturalAlgorithm-test.ts @@ -26,7 +26,7 @@ import { RoomNotificationStateStore } from "../../../../../src/stores/notificati import * as RoomNotifs from "../../../../../src/RoomNotifs"; import { getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../../test-utils"; import { DEFAULT_PUSH_RULES, makePushRule } from "../../../../test-utils/pushRules"; -import { NotificationColor } from "../../../../../src/stores/notifications/NotificationColor"; +import { NotificationLevel } from "../../../../../src/stores/notifications/NotificationLevel"; describe("NaturalAlgorithm", () => { const userId = "@alice:server.org"; @@ -197,7 +197,7 @@ describe("NaturalAlgorithm", () => { jest.spyOn(RoomNotifs, "determineUnreadState").mockReturnValue({ symbol: null, count: 0, - color: NotificationColor.None, + level: NotificationLevel.None, }); });