From acbbc1c955ed98313f7731c112990f70e50f2a4e Mon Sep 17 00:00:00 2001 From: Tangled Date: Mon, 1 Dec 2025 23:28:40 +0000 Subject: [PATCH] add more toggleable metrics adds hiding the followers, following and posts/skeets count, also adds option to hide "followed by" text renames a very small amount of experiments to be nicer to read n to be consistent also removes unused code from deer settings --- src/components/ProfileHoverCard/index.web.tsx | 59 +++++---- src/screens/Profile/Header/Metrics.tsx | 78 +++++++----- .../Profile/Header/ProfileHeaderStandard.tsx | 5 + src/screens/Settings/DeerSettings.tsx | 115 ++++++++++++++---- src/state/persisted/schema.ts | 8 ++ src/state/preferences/index.tsx | 26 ++-- 6 files changed, 209 insertions(+), 82 deletions(-) diff --git a/src/components/ProfileHoverCard/index.web.tsx b/src/components/ProfileHoverCard/index.web.tsx index 37b04303a..72b5bef3b 100644 --- a/src/components/ProfileHoverCard/index.web.tsx +++ b/src/components/ProfileHoverCard/index.web.tsx @@ -18,6 +18,9 @@ import {type NavigationProp} from '#/lib/routes/types' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeHandle} from '#/lib/strings/handles' import {useProfileShadow} from '#/state/cache/profile-shadow' +import {useDisableFollowedByMetrics} from '#/state/preferences/disable-followed-by-metrics' +import {useDisableFollowersMetrics} from '#/state/preferences/disable-followers-metrics' +import {useDisableFollowingMetrics} from '#/state/preferences/disable-following-metrics' import {useEnableSquareButtons} from '#/state/preferences/enable-square-buttons' import {useModerationOpts} from '#/state/preferences/moderation-opts' import {usePrefetchProfileQuery, useProfileQuery} from '#/state/queries/profile' @@ -463,6 +466,11 @@ function Inner({ const enableSquareButtons = useEnableSquareButtons() + // disable metrics + const disableFollowersMetrics = useDisableFollowersMetrics() + const disableFollowingMetrics = useDisableFollowingMetrics() + const disableFollowedByMetrics = useDisableFollowedByMetrics() + return ( @@ -572,28 +580,34 @@ function Inner({ {!isBlockedUser && ( <> - - - {followers} - - {pluralizedFollowers} - - - - {following} - - {pluralizedFollowings} - - - + {disableFollowersMetrics && disableFollowingMetrics ? ( null ) : + + {!disableFollowersMetrics ? ( + + {followers} + + {pluralizedFollowers} + + + ) : null} + {!disableFollowingMetrics ? ( + + {following} + + {pluralizedFollowings} + + + ) : null} + + } {profile.description?.trim() && !moderation.ui('profileView').blur ? ( @@ -606,6 +620,7 @@ function Inner({ ) : undefined} {!isMe && + !disableFollowedByMetrics && shouldShowKnownFollowers(profile.viewer?.knownFollowers) && ( - - {followers} - - {pluralizedFollowers} - - - - {following} - - {pluralizedFollowings} - - - - {formatCount(i18n, profile.postsCount || 0)}{' '} - - {plural(profile.postsCount || 0, {one: 'skeet', other: 'skeets'})} - - - + <> + {disableFollowersMetrics && disableFollowingMetrics && disablePostsMetrics ? ( null ) : + + {!disableFollowersMetrics ? ( + + {followers} + + {pluralizedFollowers} + + + ) : null} + {!disableFollowingMetrics ? ( + + {following} + + {pluralizedFollowings} + + + ) : null} + {!disablePostsMetrics ? ( + + {formatCount(i18n, profile.postsCount || 0)}{' '} + + {plural(profile.postsCount || 0, {one: 'skeet', other: 'skeets'})} + + + ) : null} + + } + ) } diff --git a/src/screens/Profile/Header/ProfileHeaderStandard.tsx b/src/screens/Profile/Header/ProfileHeaderStandard.tsx index 46c678ecb..e0d50c3bc 100644 --- a/src/screens/Profile/Header/ProfileHeaderStandard.tsx +++ b/src/screens/Profile/Header/ProfileHeaderStandard.tsx @@ -17,6 +17,7 @@ import {sanitizeHandle} from '#/lib/strings/handles' import {logger} from '#/logger' import {isIOS} from '#/platform/detection' import {type Shadow, useProfileShadow} from '#/state/cache/profile-shadow' +import {useDisableFollowedByMetrics} from '#/state/preferences/disable-followed-by-metrics' import { useProfileBlockMutationQueue, useProfileFollowMutationQueue, @@ -94,6 +95,9 @@ let ProfileHeaderStandard = ({ const {isActive: live} = useActorStatus(profile) + // disable metrics + const disableFollowedByMetrics = useDisableFollowedByMetrics() + return ( <> diff --git a/src/screens/Settings/DeerSettings.tsx b/src/screens/Settings/DeerSettings.tsx index aa629ea0c..2a82c6466 100644 --- a/src/screens/Settings/DeerSettings.tsx +++ b/src/screens/Settings/DeerSettings.tsx @@ -16,10 +16,6 @@ import { import {isWeb} from '#/platform/detection' import * as persisted from '#/state/persisted' import {useGoLinksEnabled, useSetGoLinksEnabled} from '#/state/preferences' -import { - useConstellationEnabled, - useSetConstellationEnabled, -} from '#/state/preferences/constellation-enabled' import { useConstellationInstance, useSetConstellationInstance, @@ -33,6 +29,18 @@ import { useDirectFetchRecords, useSetDirectFetchRecords, } from '#/state/preferences/direct-fetch-records' +import { + useDisableFollowersMetrics, + useSetDisableFollowersMetrics +} from '#/state/preferences/disable-followers-metrics' +import { + useDisableFollowingMetrics, + useSetDisableFollowingMetrics +} from '#/state/preferences/disable-following-metrics' +import { + useDisableFollowedByMetrics, + useSetDisableFollowedByMetrics +} from '#/state/preferences/disable-followed-by-metrics' import { useDisableLikesMetrics, useSetDisableLikesMetrics, @@ -45,6 +53,10 @@ import { useDisableReplyMetrics, useSetDisableReplyMetrics, } from '#/state/preferences/disable-reply-metrics' +import { + useDisablePostsMetrics, + useSetDisablePostsMetrics, +} from '#/state/preferences/disable-posts-metrics' import { useDisableRepostsMetrics, useSetDisableRepostsMetrics, @@ -65,6 +77,10 @@ import { useEnableSquareButtons, useSetEnableSquareButtons, } from '#/state/preferences/enable-square-buttons' +import { + useSetShowExternalShareButtons, + useShowExternalShareButtons, +} from '#/state/preferences/external-share-buttons' import { useHideFeedsPromoTab, useSetHideFeedsPromoTab, @@ -95,10 +111,6 @@ import { useShowLinkInHandle, } from '#/state/preferences/show-link-in-handle.tsx' import {useProfilesQuery} from '#/state/queries/profile' -import { - useSetShowExternalShareButtons, - useShowExternalShareButtons, -} from '#/state/preferences/external-share-buttons' import * as SettingsList from '#/screens/Settings/components/SettingsList' import {atoms as a, useBreakpoints} from '#/alf' import {Admonition} from '#/components/Admonition' @@ -250,9 +262,6 @@ export function DeerSettingsScreen({}: Props) { const goLinksEnabled = useGoLinksEnabled() const setGoLinksEnabled = useSetGoLinksEnabled() - const constellationEnabled = useConstellationEnabled() - const setConstellationEnabled = useSetConstellationEnabled() - const directFetchRecords = useDirectFetchRecords() const setDirectFetchRecords = useSetDirectFetchRecords() @@ -289,6 +298,18 @@ export function DeerSettingsScreen({}: Props) { const disableReplyMetrics = useDisableReplyMetrics() const setDisableReplyMetrics = useSetDisableReplyMetrics() + const disableFollowersMetrics = useDisableFollowersMetrics() + const setDisableFollowersMetrics = useSetDisableFollowersMetrics() + + const disableFollowingMetrics = useDisableFollowingMetrics() + const setDisableFollowingMetrics = useSetDisableFollowingMetrics() + + const disableFollowedByMetrics = useDisableFollowedByMetrics() + const setDisableFollowedByMetrics = useSetDisableFollowedByMetrics() + + const disablePostsMetrics = useDisablePostsMetrics() + const setDisablePostsMetrics = useSetDisablePostsMetrics() + const hideSimilarAccountsRecomm = useHideSimilarAccountsRecomm() const setHideSimilarAccountsRecomm = useSetHideSimilarAccountsRecomm() @@ -545,12 +566,12 @@ export function DeerSettingsScreen({}: Props) { setDisableViaRepostNotification(value)} style={[a.w_full]}> - Disable via reskeet notifications + Disable "via reskeet" notifications @@ -606,60 +627,108 @@ export function DeerSettingsScreen({}: Props) { setDisableLikesMetrics(value)} style={[a.w_full]}> - Disable Likes Metrics + Disable likes metrics setDisableRepostsMetrics(value)} style={[a.w_full]}> - Disable Reskeets Metrics + Disable reskeets metrics setDisableQuotesMetrics(value)} style={[a.w_full]}> - Disable Quotes Metrics + Disable quotes metrics setDisableSavesMetrics(value)} style={[a.w_full]}> - Disable Saves Metrics + Disable saves metrics setDisableReplyMetrics(value)} style={[a.w_full]}> - Disable Reply Metrics + Disable reply metrics + + + + + setDisableFollowersMetrics(value)} + style={[a.w_full]}> + + Disable followers metrics + + + + + setDisableFollowingMetrics(value)} + style={[a.w_full]}> + + Disable following metrics + + + + + setDisableFollowedByMetrics(value)} + style={[a.w_full]}> + + Disable "followed by" metrics + + + + + setDisablePostsMetrics(value)} + style={[a.w_full]}> + + Disable skeets metrics diff --git a/src/state/persisted/schema.ts b/src/state/persisted/schema.ts index 1fff40550..29618c1d4 100644 --- a/src/state/persisted/schema.ts +++ b/src/state/persisted/schema.ts @@ -151,6 +151,10 @@ const schema = z.object({ disableQuotesMetrics: z.boolean().optional(), disableSavesMetrics: z.boolean().optional(), disableReplyMetrics: z.boolean().optional(), + disableFollowersMetrics: z.boolean().optional(), + disableFollowingMetrics: z.boolean().optional(), + disableFollowedByMetrics: z.boolean().optional(), + disablePostsMetrics: z.boolean().optional(), hideSimilarAccountsRecomm: z.boolean().optional(), enableSquareAvatars: z.boolean().optional(), enableSquareButtons: z.boolean().optional(), @@ -234,6 +238,10 @@ export const defaults: Schema = { disableQuotesMetrics: false, disableSavesMetrics: false, disableReplyMetrics: false, + disableFollowersMetrics: false, + disableFollowingMetrics: false, + disableFollowedByMetrics: false, + disablePostsMetrics: false, hideSimilarAccountsRecomm: true, enableSquareAvatars: false, enableSquareButtons: false, diff --git a/src/state/preferences/index.tsx b/src/state/preferences/index.tsx index 1284b690e..719e891ee 100644 --- a/src/state/preferences/index.tsx +++ b/src/state/preferences/index.tsx @@ -6,8 +6,12 @@ import {Provider as ConstellationProvider} from './constellation-enabled' import {Provider as ConstellationInstanceProvider} from './constellation-instance' import {Provider as DeerVerificationProvider} from './deer-verification' import {Provider as DirectFetchRecordsProvider} from './direct-fetch-records' +import {Provider as DisableFollowedByMetricsProvider} from './disable-followed-by-metrics' +import {Provider as DisableFollowersMetricsProvider} from './disable-followers-metrics' +import {Provider as DisableFollowingMetricsProvider} from './disable-following-metrics' import {Provider as DisableHapticsProvider} from './disable-haptics' import {Provider as DisableLikesMetricsProvider} from './disable-likes-metrics' +import {Provider as DisablePostsMetricsProvider} from './disable-posts-metrics' import {Provider as DisableQuotesMetricsProvider} from './disable-quotes-metrics' import {Provider as DisableReplyMetricsProvider} from './disable-reply-metrics' import {Provider as DisableRepostsMetricsProvider} from './disable-reposts-metrics' @@ -86,13 +90,21 @@ export function Provider({children}: React.PropsWithChildren<{}>) { - - - - {children} - - - + + + + + + + + {children} + + + + + + + -- 2.51.2