isLoaded -> isReady
This commit is contained in:
@@ -24,7 +24,7 @@ const DEFAULT_AGE_ASSURANCE_STATE: AppBskyUnspeccedDefs.AgeAssuranceState = {
|
||||
}
|
||||
const AgeAssuranceContext = createContext<AgeAssuranceContextType>({
|
||||
status: 'unknown',
|
||||
isLoaded: false,
|
||||
isReady: false,
|
||||
lastInitiatedAt: undefined,
|
||||
})
|
||||
const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
|
||||
@@ -99,7 +99,7 @@ export function Provider({children}: {children: React.ReactNode}) {
|
||||
const ageAssuranceContext = useMemo<AgeAssuranceContextType>(() => {
|
||||
const {status, lastInitiatedAt} = data || DEFAULT_AGE_ASSURANCE_STATE
|
||||
const ctx: AgeAssuranceContextType = {
|
||||
isLoaded: isFetched,
|
||||
isReady: isFetched,
|
||||
status,
|
||||
lastInitiatedAt,
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user