Merge pull request #170 from CloudHub-Social/pr/feat/settings-badges
feat(settings): badge count DMs-only toggle and highlight-only app badge option
This commit is contained in:
6 files changed
+30
-3
No files matched your search
@@ -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.
|
||||
@@ -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 (
|
||||
<Badge
|
||||
|
||||
@@ -424,7 +424,11 @@ export function RoomNavItem({
|
||||
)}
|
||||
{!optionsVisible && (unread || hasRoomUnread) && (
|
||||
<UnreadBadgeCenter>
|
||||
<UnreadBadge highlight={!!unread && unread.highlight > 0} count={unreadCount} />
|
||||
<UnreadBadge
|
||||
highlight={!!unread && unread.highlight > 0}
|
||||
count={unreadCount}
|
||||
dm={direct}
|
||||
/>
|
||||
</UnreadBadgeCenter>
|
||||
)}
|
||||
{!optionsVisible && notificationMode !== RoomNotificationMode.Unset && (
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Badge Counts for DMs Only"
|
||||
description="Only show unread counts on Direct Message badges. Non-DM rooms and spaces show a plain dot instead."
|
||||
after={
|
||||
<Switch variant="Primary" value={badgeCountDMsOnly} onChange={setBadgeCountDMsOnly} />
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Unread Ping Counts"
|
||||
|
||||
@@ -111,6 +111,7 @@ export function DirectTab() {
|
||||
<UnreadBadge
|
||||
highlight={directUnread.highlight > 0}
|
||||
count={directUnread.highlight > 0 ? directUnread.highlight : directUnread.total}
|
||||
dm
|
||||
/>
|
||||
</SidebarItemBadge>
|
||||
)}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user