From 659e62ccc3c16f80bce46d6b75a00fc58d419e1d Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 15 Jul 2025 17:04:30 -0500 Subject: [PATCH] isLoaded -> isReady --- src/components/ageAssurance/AgeAssuranceAccountCard.tsx | 4 ++-- src/components/ageAssurance/AgeAssuranceAdmonition.tsx | 4 ++-- .../ageAssurance/AgeAssuranceDismissableNotice.tsx | 4 ++-- src/components/ageAssurance/AgeRestrictedScreen.tsx | 4 ++-- src/screens/Moderation/index.tsx | 4 ++-- src/state/ageAssurance/index.tsx | 4 ++-- src/state/ageAssurance/types.ts | 5 ++++- src/state/ageAssurance/useAgeInfo.ts | 6 +++--- src/state/ageAssurance/useIsAgeRestricted.ts | 6 +++--- src/state/queries/post-feed.ts | 4 ++-- 10 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/components/ageAssurance/AgeAssuranceAccountCard.tsx b/src/components/ageAssurance/AgeAssuranceAccountCard.tsx index 3c26a0cc2a..13671484bb 100644 --- a/src/components/ageAssurance/AgeAssuranceAccountCard.tsx +++ b/src/components/ageAssurance/AgeAssuranceAccountCard.tsx @@ -20,9 +20,9 @@ import {createStaticClick, InlineLinkText} from '#/components/Link' import {Text} from '#/components/Typography' export function AgeAssuranceAccountCard({style}: ViewStyleProp & {}) { - const {isLoaded, isAgeRestricted, isUnderage} = useAgeInfo() + const {isReady, isAgeRestricted, isUnderage} = useAgeInfo() - if (!isLoaded) return null + if (!isReady) return null if (isUnderage) return null if (!isAgeRestricted) return null diff --git a/src/components/ageAssurance/AgeAssuranceAdmonition.tsx b/src/components/ageAssurance/AgeAssuranceAdmonition.tsx index 8bd3b86635..0cffb156dc 100644 --- a/src/components/ageAssurance/AgeAssuranceAdmonition.tsx +++ b/src/components/ageAssurance/AgeAssuranceAdmonition.tsx @@ -15,9 +15,9 @@ export function AgeAssuranceAdmonition({ style, }: ViewStyleProp & {children: React.ReactNode}) { const control = useDialogControl() - const {isLoaded, isUnderage, isAgeRestricted} = useAgeInfo() + const {isReady, isUnderage, isAgeRestricted} = useAgeInfo() - if (!isLoaded) return null + if (!isReady) return null if (isUnderage) return null if (!isAgeRestricted) return null diff --git a/src/components/ageAssurance/AgeAssuranceDismissableNotice.tsx b/src/components/ageAssurance/AgeAssuranceDismissableNotice.tsx index 9a0abc411d..3817d8b92d 100644 --- a/src/components/ageAssurance/AgeAssuranceDismissableNotice.tsx +++ b/src/components/ageAssurance/AgeAssuranceDismissableNotice.tsx @@ -12,13 +12,13 @@ import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' export function AgeAssuranceDismissableNotice({style}: ViewStyleProp & {}) { const {_} = useLingui() - const {isLoaded, isUnderage, isAgeRestricted, assurance} = useAgeInfo() + const {isReady, isUnderage, isAgeRestricted, assurance} = useAgeInfo() const {nux} = useNux(Nux.AgeAssuranceDismissableNotice) const copy = useAgeAssuranceCopy() const {mutate: save, variables} = useSaveNux() const hidden = !!variables - if (!isLoaded) return null + if (!isReady) return null if (isUnderage) return null if (!isAgeRestricted) return null if (assurance.lastInitiatedAt) return null diff --git a/src/components/ageAssurance/AgeRestrictedScreen.tsx b/src/components/ageAssurance/AgeRestrictedScreen.tsx index 408924ed17..919af78f21 100644 --- a/src/components/ageAssurance/AgeRestrictedScreen.tsx +++ b/src/components/ageAssurance/AgeRestrictedScreen.tsx @@ -24,9 +24,9 @@ export function AgeRestrictedScreen({ }) { const {_} = useLingui() const copy = useAgeAssuranceCopy() - const {isLoaded, isAgeRestricted} = useAgeInfo() + const {isReady, isAgeRestricted} = useAgeInfo() - if (!isLoaded) { + if (!isReady) { return ( diff --git a/src/screens/Moderation/index.tsx b/src/screens/Moderation/index.tsx index f3f557658e..aa28286f71 100644 --- a/src/screens/Moderation/index.tsx +++ b/src/screens/Moderation/index.tsx @@ -86,9 +86,9 @@ export function ModerationScreen( error: preferencesError, data: preferences, } = usePreferencesQuery() - const {isLoaded: isAgeInfoLoaded} = useAgeInfo() + const {isReady: isAgeInfoReady} = useAgeInfo() - const isLoading = isPreferencesLoading || !isAgeInfoLoaded + const isLoading = isPreferencesLoading || !isAgeInfoReady const error = preferencesError return ( diff --git a/src/state/ageAssurance/index.tsx b/src/state/ageAssurance/index.tsx index d58e624ab9..633b68af9f 100644 --- a/src/state/ageAssurance/index.tsx +++ b/src/state/ageAssurance/index.tsx @@ -24,7 +24,7 @@ const DEFAULT_AGE_ASSURANCE_STATE: AppBskyUnspeccedDefs.AgeAssuranceState = { } const AgeAssuranceContext = createContext({ status: 'unknown', - isLoaded: false, + isReady: false, lastInitiatedAt: undefined, }) const AgeAssuranceAPIContext = createContext({ @@ -99,7 +99,7 @@ export function Provider({children}: {children: React.ReactNode}) { const ageAssuranceContext = useMemo(() => { const {status, lastInitiatedAt} = data || DEFAULT_AGE_ASSURANCE_STATE const ctx: AgeAssuranceContextType = { - isLoaded: isFetched, + isReady: isFetched, status, lastInitiatedAt, } diff --git a/src/state/ageAssurance/types.ts b/src/state/ageAssurance/types.ts index bb70f87c14..1152e39f54 100644 --- a/src/state/ageAssurance/types.ts +++ b/src/state/ageAssurance/types.ts @@ -2,7 +2,10 @@ import {type AppBskyUnspeccedDefs} from '@atproto/api' import {type QueryObserverBaseResult} from '@tanstack/react-query' export type AgeAssuranceContextType = { - isLoaded: boolean + /** + * Whether the age assurance state has been fetched from the server. + */ + isReady: boolean /** * The server-reported status of the user's age verification process. */ diff --git a/src/state/ageAssurance/useAgeInfo.ts b/src/state/ageAssurance/useAgeInfo.ts index c02da96384..380b912052 100644 --- a/src/state/ageAssurance/useAgeInfo.ts +++ b/src/state/ageAssurance/useAgeInfo.ts @@ -8,7 +8,7 @@ import {usePreferencesQuery} from '#/state/queries/preferences' const logger = Logger.create(Logger.Context.AgeAssurance) type AgeInfo = { - isLoaded: boolean + isReady: boolean declaredAge: number | undefined isUnderage: boolean isAgeRestricted: boolean @@ -28,10 +28,10 @@ export function useAgeInfo(): AgeInfo { const declaredAge = preferences?.userAge return useMemo(() => { - const isLoaded = ctx.isLoaded && preferencesLoaded + const isReady = ctx.isReady && preferencesLoaded const isUnderage = (declaredAge || 0) < 18 const info: AgeInfo = { - isLoaded, + isReady, declaredAge, isUnderage, isAgeRestricted, diff --git a/src/state/ageAssurance/useIsAgeRestricted.ts b/src/state/ageAssurance/useIsAgeRestricted.ts index 848f30bdd9..0bdef9f493 100644 --- a/src/state/ageAssurance/useIsAgeRestricted.ts +++ b/src/state/ageAssurance/useIsAgeRestricted.ts @@ -5,7 +5,7 @@ import {useAgeAssuranceContext} from '#/state/ageAssurance' import {useGeolocation} from '#/state/geolocation' export function useIsAgeRestricted() { - const {isLoaded, status} = useAgeAssuranceContext() + const {isReady, status} = useAgeAssuranceContext() const {geolocation} = useGeolocation() const gate = useGate() @@ -17,8 +17,8 @@ export function useIsAgeRestricted() { } } return { - isReady: isLoaded, + isReady, isAgeRestricted: status !== 'assured', } - }, [isLoaded, status, geolocation, gate]) + }, [isReady, status, geolocation, gate]) } diff --git a/src/state/queries/post-feed.ts b/src/state/queries/post-feed.ts index 076543444c..9738f53e5c 100644 --- a/src/state/queries/post-feed.ts +++ b/src/state/queries/post-feed.ts @@ -139,12 +139,12 @@ export function usePostFeedQuery( /** * Load bearing: we need to await AA state or risk FOUC. */ - const {isLoaded: isAALoaded} = useAgeAssuranceContext() + const {isReady: isAgeAssuranceReady} = useAgeAssuranceContext() const enabled = opts?.enabled !== false && Boolean(moderationOpts) && Boolean(preferences) && - isAALoaded + isAgeAssuranceReady const userInterests = aggregateUserInterests(preferences) const followingPinnedIndex = preferences?.savedFeeds?.findIndex(