isLoaded -> isReady
This commit is contained in:
@@ -20,9 +20,9 @@ import {createStaticClick, InlineLinkText} from '#/components/Link'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
export function AgeAssuranceAccountCard({style}: ViewStyleProp & {}) {
|
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 (isUnderage) return null
|
||||||
if (!isAgeRestricted) return null
|
if (!isAgeRestricted) return null
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ export function AgeAssuranceAdmonition({
|
|||||||
style,
|
style,
|
||||||
}: ViewStyleProp & {children: React.ReactNode}) {
|
}: ViewStyleProp & {children: React.ReactNode}) {
|
||||||
const control = useDialogControl()
|
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 (isUnderage) return null
|
||||||
if (!isAgeRestricted) return null
|
if (!isAgeRestricted) return null
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
|
|||||||
|
|
||||||
export function AgeAssuranceDismissableNotice({style}: ViewStyleProp & {}) {
|
export function AgeAssuranceDismissableNotice({style}: ViewStyleProp & {}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {isLoaded, isUnderage, isAgeRestricted, assurance} = useAgeInfo()
|
const {isReady, isUnderage, isAgeRestricted, assurance} = useAgeInfo()
|
||||||
const {nux} = useNux(Nux.AgeAssuranceDismissableNotice)
|
const {nux} = useNux(Nux.AgeAssuranceDismissableNotice)
|
||||||
const copy = useAgeAssuranceCopy()
|
const copy = useAgeAssuranceCopy()
|
||||||
const {mutate: save, variables} = useSaveNux()
|
const {mutate: save, variables} = useSaveNux()
|
||||||
const hidden = !!variables
|
const hidden = !!variables
|
||||||
|
|
||||||
if (!isLoaded) return null
|
if (!isReady) return null
|
||||||
if (isUnderage) return null
|
if (isUnderage) return null
|
||||||
if (!isAgeRestricted) return null
|
if (!isAgeRestricted) return null
|
||||||
if (assurance.lastInitiatedAt) return null
|
if (assurance.lastInitiatedAt) return null
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ export function AgeRestrictedScreen({
|
|||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const copy = useAgeAssuranceCopy()
|
const copy = useAgeAssuranceCopy()
|
||||||
const {isLoaded, isAgeRestricted} = useAgeInfo()
|
const {isReady, isAgeRestricted} = useAgeInfo()
|
||||||
|
|
||||||
if (!isLoaded) {
|
if (!isReady) {
|
||||||
return (
|
return (
|
||||||
<Layout.Screen>
|
<Layout.Screen>
|
||||||
<Layout.Header.Outer>
|
<Layout.Header.Outer>
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ export function ModerationScreen(
|
|||||||
error: preferencesError,
|
error: preferencesError,
|
||||||
data: preferences,
|
data: preferences,
|
||||||
} = usePreferencesQuery()
|
} = usePreferencesQuery()
|
||||||
const {isLoaded: isAgeInfoLoaded} = useAgeInfo()
|
const {isReady: isAgeInfoReady} = useAgeInfo()
|
||||||
|
|
||||||
const isLoading = isPreferencesLoading || !isAgeInfoLoaded
|
const isLoading = isPreferencesLoading || !isAgeInfoReady
|
||||||
const error = preferencesError
|
const error = preferencesError
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const DEFAULT_AGE_ASSURANCE_STATE: AppBskyUnspeccedDefs.AgeAssuranceState = {
|
|||||||
}
|
}
|
||||||
const AgeAssuranceContext = createContext<AgeAssuranceContextType>({
|
const AgeAssuranceContext = createContext<AgeAssuranceContextType>({
|
||||||
status: 'unknown',
|
status: 'unknown',
|
||||||
isLoaded: false,
|
isReady: false,
|
||||||
lastInitiatedAt: undefined,
|
lastInitiatedAt: undefined,
|
||||||
})
|
})
|
||||||
const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
|
const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
|
||||||
@@ -99,7 +99,7 @@ export function Provider({children}: {children: React.ReactNode}) {
|
|||||||
const ageAssuranceContext = useMemo<AgeAssuranceContextType>(() => {
|
const ageAssuranceContext = useMemo<AgeAssuranceContextType>(() => {
|
||||||
const {status, lastInitiatedAt} = data || DEFAULT_AGE_ASSURANCE_STATE
|
const {status, lastInitiatedAt} = data || DEFAULT_AGE_ASSURANCE_STATE
|
||||||
const ctx: AgeAssuranceContextType = {
|
const ctx: AgeAssuranceContextType = {
|
||||||
isLoaded: isFetched,
|
isReady: isFetched,
|
||||||
status,
|
status,
|
||||||
lastInitiatedAt,
|
lastInitiatedAt,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import {type AppBskyUnspeccedDefs} from '@atproto/api'
|
|||||||
import {type QueryObserverBaseResult} from '@tanstack/react-query'
|
import {type QueryObserverBaseResult} from '@tanstack/react-query'
|
||||||
|
|
||||||
export type AgeAssuranceContextType = {
|
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.
|
* The server-reported status of the user's age verification process.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {usePreferencesQuery} from '#/state/queries/preferences'
|
|||||||
const logger = Logger.create(Logger.Context.AgeAssurance)
|
const logger = Logger.create(Logger.Context.AgeAssurance)
|
||||||
|
|
||||||
type AgeInfo = {
|
type AgeInfo = {
|
||||||
isLoaded: boolean
|
isReady: boolean
|
||||||
declaredAge: number | undefined
|
declaredAge: number | undefined
|
||||||
isUnderage: boolean
|
isUnderage: boolean
|
||||||
isAgeRestricted: boolean
|
isAgeRestricted: boolean
|
||||||
@@ -28,10 +28,10 @@ export function useAgeInfo(): AgeInfo {
|
|||||||
const declaredAge = preferences?.userAge
|
const declaredAge = preferences?.userAge
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
const isLoaded = ctx.isLoaded && preferencesLoaded
|
const isReady = ctx.isReady && preferencesLoaded
|
||||||
const isUnderage = (declaredAge || 0) < 18
|
const isUnderage = (declaredAge || 0) < 18
|
||||||
const info: AgeInfo = {
|
const info: AgeInfo = {
|
||||||
isLoaded,
|
isReady,
|
||||||
declaredAge,
|
declaredAge,
|
||||||
isUnderage,
|
isUnderage,
|
||||||
isAgeRestricted,
|
isAgeRestricted,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {useAgeAssuranceContext} from '#/state/ageAssurance'
|
|||||||
import {useGeolocation} from '#/state/geolocation'
|
import {useGeolocation} from '#/state/geolocation'
|
||||||
|
|
||||||
export function useIsAgeRestricted() {
|
export function useIsAgeRestricted() {
|
||||||
const {isLoaded, status} = useAgeAssuranceContext()
|
const {isReady, status} = useAgeAssuranceContext()
|
||||||
const {geolocation} = useGeolocation()
|
const {geolocation} = useGeolocation()
|
||||||
const gate = useGate()
|
const gate = useGate()
|
||||||
|
|
||||||
@@ -17,8 +17,8 @@ export function useIsAgeRestricted() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
isReady: isLoaded,
|
isReady,
|
||||||
isAgeRestricted: status !== 'assured',
|
isAgeRestricted: status !== 'assured',
|
||||||
}
|
}
|
||||||
}, [isLoaded, status, geolocation, gate])
|
}, [isReady, status, geolocation, gate])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,12 +139,12 @@ export function usePostFeedQuery(
|
|||||||
/**
|
/**
|
||||||
* Load bearing: we need to await AA state or risk FOUC.
|
* Load bearing: we need to await AA state or risk FOUC.
|
||||||
*/
|
*/
|
||||||
const {isLoaded: isAALoaded} = useAgeAssuranceContext()
|
const {isReady: isAgeAssuranceReady} = useAgeAssuranceContext()
|
||||||
const enabled =
|
const enabled =
|
||||||
opts?.enabled !== false &&
|
opts?.enabled !== false &&
|
||||||
Boolean(moderationOpts) &&
|
Boolean(moderationOpts) &&
|
||||||
Boolean(preferences) &&
|
Boolean(preferences) &&
|
||||||
isAALoaded
|
isAgeAssuranceReady
|
||||||
const userInterests = aggregateUserInterests(preferences)
|
const userInterests = aggregateUserInterests(preferences)
|
||||||
const followingPinnedIndex =
|
const followingPinnedIndex =
|
||||||
preferences?.savedFeeds?.findIndex(
|
preferences?.savedFeeds?.findIndex(
|
||||||
|
|||||||
Reference in New Issue
Block a user