From e3c74ef44af1fb12bda455555fd1be668dd84c4b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 25 Jun 2025 21:33:02 -0500 Subject: [PATCH] Comments --- src/lib/notifications/notifications.ts | 5 +++++ src/state/ageAssurance.tsx | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts index c6e6f4c4fe..d5fa3edd85 100644 --- a/src/lib/notifications/notifications.ts +++ b/src/lib/notifications/notifications.ts @@ -65,6 +65,11 @@ const _registerPushTokenDebounced = debounce(_registerPushToken, 100) export function useRegisterPushToken() { const agent = useAgent() 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() return useCallback( diff --git a/src/state/ageAssurance.tsx b/src/state/ageAssurance.tsx index b3af652f72..c6d96b8f67 100644 --- a/src/state/ageAssurance.tsx +++ b/src/state/ageAssurance.tsx @@ -14,11 +14,21 @@ type TempAgeAssuranceState = { } export type AgeAssuranceContextType = { + /** + * Whether the current user is age-restricted based on their geolocation and + * age assurance state retrieved from the server. + */ isAgeRestricted: boolean + /** + * The current age assurance status retrieved from the server. + */ status: TempAgeAssuranceState['status'] } export type AgeAssuranceAPIContextType = { + /** + * Refreshes the age assurance state by fetching it from the server. + */ refresh: () => Promise } @@ -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() { return useContext(AgeAssuranceContext) }