diff --git a/.changeset/badge_count_dms_only_setting.md b/.changeset/badge_count_dms_only_setting.md new file mode 100644 index 00000000..17dd88d8 --- /dev/null +++ b/.changeset/badge_count_dms_only_setting.md @@ -0,0 +1,5 @@ +--- +sable: minor +--- + +Added a "Badge Counts for DMs Only" setting: when enabled, unread count numbers only appear on Direct Message room badges; non-DM rooms and spaces show a plain dot instead of a number, even when Show Unread Counts is on. diff --git a/src/app/components/unread-badge/UnreadBadge.tsx b/src/app/components/unread-badge/UnreadBadge.tsx index 49b8d664..4648ae05 100644 --- a/src/app/components/unread-badge/UnreadBadge.tsx +++ b/src/app/components/unread-badge/UnreadBadge.tsx @@ -7,6 +7,8 @@ import { settingsAtom } from '$state/settings'; type UnreadBadgeProps = { highlight?: boolean; count: number; + /** Whether this badge belongs to a DM room. Used with the badgeCountDMsOnly setting. */ + dm?: boolean; }; const styles: CSSProperties = { minWidth: toRem(16), @@ -19,11 +21,14 @@ export function UnreadBadgeCenter({ children }: { children: ReactNode }) { ); } -export function UnreadBadge({ highlight, count }: UnreadBadgeProps) { +export function UnreadBadge({ highlight, count, dm }: UnreadBadgeProps) { const [showUnreadCounts] = useSetting(settingsAtom, 'showUnreadCounts'); + const [badgeCountDMsOnly] = useSetting(settingsAtom, 'badgeCountDMsOnly'); const [showPingCounts] = useSetting(settingsAtom, 'showPingCounts'); - const showNumber = count > 0 && (showUnreadCounts || (highlight && showPingCounts)); + // Show count when: (showUnreadCounts OR highlight+showPingCounts) AND (not DM-only mode OR this is a DM) + const showNumber = + count > 0 && (showUnreadCounts || (highlight && showPingCounts)) && (!badgeCountDMsOnly || dm); return ( - 0} count={unreadCount} /> + 0} + count={unreadCount} + dm={direct} + /> )} {!optionsVisible && notificationMode !== RoomNotificationMode.Unset && ( diff --git a/src/app/features/settings/cosmetics/Themes.tsx b/src/app/features/settings/cosmetics/Themes.tsx index 56d73c24..714bbd57 100644 --- a/src/app/features/settings/cosmetics/Themes.tsx +++ b/src/app/features/settings/cosmetics/Themes.tsx @@ -328,6 +328,7 @@ function PageZoomInput() { export function Appearance() { const [twitterEmoji, setTwitterEmoji] = useSetting(settingsAtom, 'twitterEmoji'); const [showUnreadCounts, setShowUnreadCounts] = useSetting(settingsAtom, 'showUnreadCounts'); + const [badgeCountDMsOnly, setBadgeCountDMsOnly] = useSetting(settingsAtom, 'badgeCountDMsOnly'); const [showPingCounts, setShowPingCounts] = useSetting(settingsAtom, 'showPingCounts'); return ( @@ -357,6 +358,15 @@ export function Appearance() { } /> + + + } + /> + 0} count={directUnread.highlight > 0 ? directUnread.highlight : directUnread.total} + dm /> )} diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index fab45528..cdbd95a5 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -72,6 +72,7 @@ export interface Settings { hideMembershipInReadOnly: boolean; useRightBubbles: boolean; showUnreadCounts: boolean; + badgeCountDMsOnly: boolean; showPingCounts: boolean; } @@ -129,6 +130,7 @@ const defaultSettings: Settings = { hideMembershipInReadOnly: true, useRightBubbles: false, showUnreadCounts: true, + badgeCountDMsOnly: false, showPingCounts: true, };