This commit is contained in:
Eric Bailey
2025-06-25 21:33:02 -05:00
parent 404f837248
commit e3c74ef44a
2 changed files with 21 additions and 0 deletions
+5
View File
@@ -65,6 +65,11 @@ const _registerPushTokenDebounced = debounce(_registerPushToken, 100)
export function useRegisterPushToken() { export function useRegisterPushToken() {
const agent = useAgent() const agent = useAgent()
const {currentAccount} = useSession() const {currentAccount} = useSession()
/**
* At the time of writing, this data is guaranteed to be available here,
* since we await both geolocation and age assurance requirements before
* rendering `shell/index.tsx`.
*/
const {isAgeRestricted} = useAgeAssuranceContext() const {isAgeRestricted} = useAgeAssuranceContext()
return useCallback( return useCallback(
+16
View File
@@ -14,11 +14,21 @@ type TempAgeAssuranceState = {
} }
export type AgeAssuranceContextType = { export type AgeAssuranceContextType = {
/**
* Whether the current user is age-restricted based on their geolocation and
* age assurance state retrieved from the server.
*/
isAgeRestricted: boolean isAgeRestricted: boolean
/**
* The current age assurance status retrieved from the server.
*/
status: TempAgeAssuranceState['status'] status: TempAgeAssuranceState['status']
} }
export type AgeAssuranceAPIContextType = { export type AgeAssuranceAPIContextType = {
/**
* Refreshes the age assurance state by fetching it from the server.
*/
refresh: () => Promise<void> refresh: () => Promise<void>
} }
@@ -91,6 +101,12 @@ export function Provider({children}: {children: React.ReactNode}) {
) )
} }
/**
* Returns the current age assurance state from context. This data is awaited
* prior to rendering the app, and therefore the data here should be up to date
* and trustworth by the time we're rendering anything inside the `Splash`
* wrapper in the root component files.
*/
export function useAgeAssuranceContext() { export function useAgeAssuranceContext() {
return useContext(AgeAssuranceContext) return useContext(AgeAssuranceContext)
} }