From 22b79a133e1d13c59e7c97aaa3c9453ece50df09 Mon Sep 17 00:00:00 2001 From: DS Boyce <260543580+ds-boyce@users.noreply.github.com> Date: Thu, 15 Oct 2026 09:41:45 -0700 Subject: [PATCH] Add unread count to Moderation and content filters (#11991) --- src/lib/constants.ts | 3 ++ src/screens/Moderation/index.tsx | 3 +- src/screens/Settings/Settings.tsx | 24 ++++++++++- .../Settings/components/SettingsList.tsx | 43 ++++++++++++++++++- 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 568189221..a4c7d2643 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -77,6 +77,9 @@ export const MAX_ALT_TEXT = 2000 export const MAX_REPORT_REASON_GRAPHEME_LENGTH = 2000 +/** Moderation inbox badges display 99+ at or above this unread count. */ +export const UNREAD_NOTIFICATION_CAP = 100 + export function IS_TEST_USER(handle?: string) { return handle && handle?.endsWith('.test') } diff --git a/src/screens/Moderation/index.tsx b/src/screens/Moderation/index.tsx index 30cd06590..5e9bc8413 100644 --- a/src/screens/Moderation/index.tsx +++ b/src/screens/Moderation/index.tsx @@ -4,6 +4,7 @@ import {LABELS} from '@bsky/sdk/moderation' import {plural} from '@lingui/core/macro' import {Trans, useLingui} from '@lingui/react/macro' +import {UNREAD_NOTIFICATION_CAP} from '#/lib/constants' import {getLabelingServiceTitle, isAppLabeler} from '#/lib/moderation' import { type CommonNavigatorParams, @@ -49,8 +50,6 @@ import {useAgeAssurance} from '#/ageAssurance' import {useAnalytics} from '#/analytics' import {IS_IOS} from '#/env' -const UNREAD_NOTIFICATION_CAP = 100 - function ErrorState({error}: {error: string}) { const t = useTheme() return ( diff --git a/src/screens/Settings/Settings.tsx b/src/screens/Settings/Settings.tsx index 61af150a9..a469e8e55 100644 --- a/src/screens/Settings/Settings.tsx +++ b/src/screens/Settings/Settings.tsx @@ -3,6 +3,7 @@ import {Alert, LayoutAnimation, Linking, Pressable, View} from 'react-native' import {useReducedMotion} from 'react-native-reanimated' import {removeNuxs} from '@bsky/sdk' import {moderateProfile} from '@bsky/sdk/moderation' +import {plural} from '@lingui/core/macro' import {Trans, useLingui} from '@lingui/react/macro' import {useNavigation} from '@react-navigation/native' import {type NativeStackScreenProps} from '@react-navigation/native-stack' @@ -21,6 +22,7 @@ import * as persisted from '#/state/persisted' import {clearStorage} from '#/state/persisted' import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useDeleteActorDeclaration} from '#/state/queries/messages/actor-declaration' +import {useModerationInboxUnreadCountQuery} from '#/state/queries/moderation-inbox' import {useProfileQuery, useProfilesQuery} from '#/state/queries/profile' import {usePdsClient} from '#/state/session' import {type SessionAccount, useSession, useSessionApi} from '#/state/session' @@ -76,6 +78,15 @@ type Props = NativeStackScreenProps export function SettingsScreen({}: Props) { const ax = useAnalytics() const {t: l} = useLingui() + const isModerationInboxEnabled = ax.features.enabled( + ax.features.ModerationInboxEnable, + ) + const unreadCountQuery = useModerationInboxUnreadCountQuery( + isModerationInboxEnabled, + ) + const unreadCount = isModerationInboxEnabled + ? (unreadCountQuery.data?.unreadCounts.total ?? 0) + : 0 const reducedMotion = useReducedMotion() const {logoutEveryAccount} = useSessionApi() const {accounts, currentAccount} = useSession() @@ -190,11 +201,20 @@ export function SettingsScreen({}: Props) { + label={l`Moderation tools`} + accessibilityHint={ + unreadCount > 0 + ? plural(unreadCount, { + one: '# unread update', + other: '# unread updates', + }) + : undefined + }> - Moderation and content filters + Moderation tools + + + {count >= UNREAD_NOTIFICATION_CAP + ? l({ + message: `${i18n.number(UNREAD_NOTIFICATION_CAP - 1)}+`, + comment: + 'Displayed when the number of notifications exceeds the cap – for example, 99+', + }) + : i18n.number(count)} + + + ) +} + export function BadgeButton({ label, onPress, -- knotmirror 0.0.1