Gate it
This commit is contained in:
+2
-2
@@ -137,9 +137,9 @@ function InnerApp() {
|
|||||||
// Resets the entire tree below when it changes:
|
// Resets the entire tree below when it changes:
|
||||||
key={currentAccount?.did}>
|
key={currentAccount?.did}>
|
||||||
<QueryProvider currentDid={currentAccount?.did}>
|
<QueryProvider currentDid={currentAccount?.did}>
|
||||||
|
<StatsigProvider>
|
||||||
<AgeAssuranceProvider>
|
<AgeAssuranceProvider>
|
||||||
<ComposerProvider>
|
<ComposerProvider>
|
||||||
<StatsigProvider>
|
|
||||||
<MessagesProvider>
|
<MessagesProvider>
|
||||||
{/* LabelDefsProvider MUST come before ModerationOptsProvider */}
|
{/* LabelDefsProvider MUST come before ModerationOptsProvider */}
|
||||||
<LabelDefsProvider>
|
<LabelDefsProvider>
|
||||||
@@ -177,9 +177,9 @@ function InnerApp() {
|
|||||||
</ModerationOptsProvider>
|
</ModerationOptsProvider>
|
||||||
</LabelDefsProvider>
|
</LabelDefsProvider>
|
||||||
</MessagesProvider>
|
</MessagesProvider>
|
||||||
</StatsigProvider>
|
|
||||||
</ComposerProvider>
|
</ComposerProvider>
|
||||||
</AgeAssuranceProvider>
|
</AgeAssuranceProvider>
|
||||||
|
</StatsigProvider>
|
||||||
</QueryProvider>
|
</QueryProvider>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
</VideoVolumeProvider>
|
</VideoVolumeProvider>
|
||||||
|
|||||||
+2
-2
@@ -117,9 +117,9 @@ function InnerApp() {
|
|||||||
// Resets the entire tree below when it changes:
|
// Resets the entire tree below when it changes:
|
||||||
key={currentAccount?.did}>
|
key={currentAccount?.did}>
|
||||||
<QueryProvider currentDid={currentAccount?.did}>
|
<QueryProvider currentDid={currentAccount?.did}>
|
||||||
|
<StatsigProvider>
|
||||||
<AgeAssuranceProvider>
|
<AgeAssuranceProvider>
|
||||||
<ComposerProvider>
|
<ComposerProvider>
|
||||||
<StatsigProvider>
|
|
||||||
<MessagesProvider>
|
<MessagesProvider>
|
||||||
{/* LabelDefsProvider MUST come before ModerationOptsProvider */}
|
{/* LabelDefsProvider MUST come before ModerationOptsProvider */}
|
||||||
<LabelDefsProvider>
|
<LabelDefsProvider>
|
||||||
@@ -153,9 +153,9 @@ function InnerApp() {
|
|||||||
</ModerationOptsProvider>
|
</ModerationOptsProvider>
|
||||||
</LabelDefsProvider>
|
</LabelDefsProvider>
|
||||||
</MessagesProvider>
|
</MessagesProvider>
|
||||||
</StatsigProvider>
|
|
||||||
</ComposerProvider>
|
</ComposerProvider>
|
||||||
</AgeAssuranceProvider>
|
</AgeAssuranceProvider>
|
||||||
|
</StatsigProvider>
|
||||||
</QueryProvider>
|
</QueryProvider>
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export type Gate =
|
export type Gate =
|
||||||
// Keep this alphabetic please.
|
// Keep this alphabetic please.
|
||||||
|
| 'age_assurance'
|
||||||
| 'alt_share_icon'
|
| 'alt_share_icon'
|
||||||
| 'debug_show_feedcontext'
|
| 'debug_show_feedcontext'
|
||||||
| 'debug_subscriptions'
|
| 'debug_subscriptions'
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {useQuery} from '@tanstack/react-query'
|
|||||||
|
|
||||||
import {networkRetry} from '#/lib/async/retry'
|
import {networkRetry} from '#/lib/async/retry'
|
||||||
import {useGetAndRegisterPushToken} from '#/lib/notifications/notifications'
|
import {useGetAndRegisterPushToken} from '#/lib/notifications/notifications'
|
||||||
|
import {useGate} from '#/lib/statsig/statsig'
|
||||||
// import {wait} from '#/lib/async/wait'
|
// import {wait} from '#/lib/async/wait'
|
||||||
import {isNetworkError} from '#/lib/strings/errors'
|
import {isNetworkError} from '#/lib/strings/errors'
|
||||||
import {Logger} from '#/logger'
|
import {Logger} from '#/logger'
|
||||||
@@ -39,6 +40,7 @@ export function Provider({children}: {children: React.ReactNode}) {
|
|||||||
const {geolocation} = useGeolocation()
|
const {geolocation} = useGeolocation()
|
||||||
const getAndRegisterPushToken = useGetAndRegisterPushToken()
|
const getAndRegisterPushToken = useGetAndRegisterPushToken()
|
||||||
const isAgeRestrictedGeo = !!geolocation?.isAgeRestrictedGeo
|
const isAgeRestrictedGeo = !!geolocation?.isAgeRestrictedGeo
|
||||||
|
const gate = useGate()
|
||||||
|
|
||||||
const {data, isFetched, refetch} = useQuery({
|
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 ageAssuranceContext = useMemo<AgeAssuranceContextType>(() => {
|
||||||
|
const enabled = gate('age_assurance')
|
||||||
const {status, lastInitiatedAt} = data || DEFAULT_AGE_ASSURANCE_STATE
|
const {status, lastInitiatedAt} = data || DEFAULT_AGE_ASSURANCE_STATE
|
||||||
const ctx: AgeAssuranceContextType = {
|
const ctx: AgeAssuranceContextType = {
|
||||||
status,
|
status,
|
||||||
isLoaded: isFetched,
|
isLoaded: isFetched,
|
||||||
lastInitiatedAt,
|
lastInitiatedAt,
|
||||||
hasInitiated: !!lastInitiatedAt,
|
hasInitiated: !!lastInitiatedAt,
|
||||||
isExempt: !isAgeRestrictedGeo,
|
isExempt: !isAgeRestrictedGeo || !enabled,
|
||||||
isAgeRestricted: Boolean(isAgeRestrictedGeo && status !== 'assured'),
|
isAgeRestricted: Boolean(isAgeRestrictedGeo && status !== 'assured'),
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(`context`, ctx)
|
logger.debug(`context`, ctx)
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
}, [isAgeRestrictedGeo, isFetched, data])
|
}, [gate, isAgeRestrictedGeo, isFetched, data])
|
||||||
|
|
||||||
const ageAssuranceAPIContext = useMemo<AgeAssuranceAPIContextType>(
|
const ageAssuranceAPIContext = useMemo<AgeAssuranceAPIContextType>(
|
||||||
() => ({
|
() => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user