Gate it
This commit is contained in:
+6
-6
@@ -137,9 +137,9 @@ function InnerApp() {
|
||||
// Resets the entire tree below when it changes:
|
||||
key={currentAccount?.did}>
|
||||
<QueryProvider currentDid={currentAccount?.did}>
|
||||
<AgeAssuranceProvider>
|
||||
<ComposerProvider>
|
||||
<StatsigProvider>
|
||||
<StatsigProvider>
|
||||
<AgeAssuranceProvider>
|
||||
<ComposerProvider>
|
||||
<MessagesProvider>
|
||||
{/* LabelDefsProvider MUST come before ModerationOptsProvider */}
|
||||
<LabelDefsProvider>
|
||||
@@ -177,9 +177,9 @@ function InnerApp() {
|
||||
</ModerationOptsProvider>
|
||||
</LabelDefsProvider>
|
||||
</MessagesProvider>
|
||||
</StatsigProvider>
|
||||
</ComposerProvider>
|
||||
</AgeAssuranceProvider>
|
||||
</ComposerProvider>
|
||||
</AgeAssuranceProvider>
|
||||
</StatsigProvider>
|
||||
</QueryProvider>
|
||||
</React.Fragment>
|
||||
</VideoVolumeProvider>
|
||||
|
||||
+6
-6
@@ -117,9 +117,9 @@ function InnerApp() {
|
||||
// Resets the entire tree below when it changes:
|
||||
key={currentAccount?.did}>
|
||||
<QueryProvider currentDid={currentAccount?.did}>
|
||||
<AgeAssuranceProvider>
|
||||
<ComposerProvider>
|
||||
<StatsigProvider>
|
||||
<StatsigProvider>
|
||||
<AgeAssuranceProvider>
|
||||
<ComposerProvider>
|
||||
<MessagesProvider>
|
||||
{/* LabelDefsProvider MUST come before ModerationOptsProvider */}
|
||||
<LabelDefsProvider>
|
||||
@@ -153,9 +153,9 @@ function InnerApp() {
|
||||
</ModerationOptsProvider>
|
||||
</LabelDefsProvider>
|
||||
</MessagesProvider>
|
||||
</StatsigProvider>
|
||||
</ComposerProvider>
|
||||
</AgeAssuranceProvider>
|
||||
</ComposerProvider>
|
||||
</AgeAssuranceProvider>
|
||||
</StatsigProvider>
|
||||
</QueryProvider>
|
||||
<ToastContainer />
|
||||
</React.Fragment>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export type Gate =
|
||||
// Keep this alphabetic please.
|
||||
| 'age_assurance'
|
||||
| 'alt_share_icon'
|
||||
| 'debug_show_feedcontext'
|
||||
| 'debug_subscriptions'
|
||||
|
||||
@@ -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<AgeAssuranceContextType>(() => {
|
||||
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<AgeAssuranceAPIContextType>(
|
||||
() => ({
|
||||
|
||||
Reference in New Issue
Block a user