From 9ee16df2504424bf153e5277916af9ffe03372ea Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Fri, 11 Jul 2025 11:14:45 -0500 Subject: [PATCH] Gate it --- src/App.native.tsx | 12 ++++++------ src/App.web.tsx | 12 ++++++------ src/lib/statsig/gates.ts | 1 + src/state/age-assurance/index.tsx | 10 ++++++++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/App.native.tsx b/src/App.native.tsx index 3818d29860..79994b7ef5 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -137,9 +137,9 @@ function InnerApp() { // Resets the entire tree below when it changes: key={currentAccount?.did}> - - - + + + {/* LabelDefsProvider MUST come before ModerationOptsProvider */} @@ -177,9 +177,9 @@ function InnerApp() { - - - + + + diff --git a/src/App.web.tsx b/src/App.web.tsx index c591c1d5b8..ebff97e6d7 100644 --- a/src/App.web.tsx +++ b/src/App.web.tsx @@ -117,9 +117,9 @@ function InnerApp() { // Resets the entire tree below when it changes: key={currentAccount?.did}> - - - + + + {/* LabelDefsProvider MUST come before ModerationOptsProvider */} @@ -153,9 +153,9 @@ function InnerApp() { - - - + + + diff --git a/src/lib/statsig/gates.ts b/src/lib/statsig/gates.ts index 3b1106480d..efd7d605a0 100644 --- a/src/lib/statsig/gates.ts +++ b/src/lib/statsig/gates.ts @@ -1,5 +1,6 @@ export type Gate = // Keep this alphabetic please. + | 'age_assurance' | 'alt_share_icon' | 'debug_show_feedcontext' | 'debug_subscriptions' diff --git a/src/state/age-assurance/index.tsx b/src/state/age-assurance/index.tsx index 84e93105b0..d0d5104512 100644 --- a/src/state/age-assurance/index.tsx +++ b/src/state/age-assurance/index.tsx @@ -4,6 +4,7 @@ import {useQuery} from '@tanstack/react-query' import {networkRetry} from '#/lib/async/retry' import {useGetAndRegisterPushToken} from '#/lib/notifications/notifications' +import {useGate} from '#/lib/statsig/statsig' // import {wait} from '#/lib/async/wait' import {isNetworkError} from '#/lib/strings/errors' import {Logger} from '#/logger' @@ -39,6 +40,7 @@ export function Provider({children}: {children: React.ReactNode}) { const {geolocation} = useGeolocation() const getAndRegisterPushToken = useGetAndRegisterPushToken() const isAgeRestrictedGeo = !!geolocation?.isAgeRestrictedGeo + const gate = useGate() const {data, isFetched, refetch} = useQuery({ /** @@ -90,21 +92,25 @@ export function Provider({children}: {children: React.ReactNode}) { }, }) + /** + * Derive state, or fall back to defaults + */ const ageAssuranceContext = useMemo(() => { + const enabled = gate('age_assurance') const {status, lastInitiatedAt} = data || DEFAULT_AGE_ASSURANCE_STATE const ctx: AgeAssuranceContextType = { status, isLoaded: isFetched, lastInitiatedAt, hasInitiated: !!lastInitiatedAt, - isExempt: !isAgeRestrictedGeo, + isExempt: !isAgeRestrictedGeo || !enabled, isAgeRestricted: Boolean(isAgeRestrictedGeo && status !== 'assured'), } logger.debug(`context`, ctx) return ctx - }, [isAgeRestrictedGeo, isFetched, data]) + }, [gate, isAgeRestrictedGeo, isFetched, data]) const ageAssuranceAPIContext = useMemo( () => ({