@@ -1,6 +1,5 @@
|
|||||||
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,7 +4,6 @@ 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 {isNetworkError} from '#/lib/strings/errors'
|
import {isNetworkError} from '#/lib/strings/errors'
|
||||||
import {
|
import {
|
||||||
type AgeAssuranceAPIContextType,
|
type AgeAssuranceAPIContextType,
|
||||||
@@ -41,7 +40,6 @@ const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
|
|||||||
* performance.
|
* performance.
|
||||||
*/
|
*/
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const gate = useGate()
|
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const {geolocation} = useGeolocation()
|
const {geolocation} = useGeolocation()
|
||||||
const isAgeAssuranceEnabled = useIsAgeAssuranceEnabled()
|
const isAgeAssuranceEnabled = useIsAgeAssuranceEnabled()
|
||||||
@@ -78,12 +76,10 @@ export function Provider({children}: {children: React.ReactNode}) {
|
|||||||
account: agent.session?.did,
|
account: agent.session?.did,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (gate('age_assurance')) {
|
await getAndRegisterPushToken({
|
||||||
await getAndRegisterPushToken({
|
isAgeRestricted:
|
||||||
isAgeRestricted:
|
!!geolocation?.isAgeRestrictedGeo && data.status !== 'assured',
|
||||||
!!geolocation?.isAgeRestrictedGeo && data.status !== 'assured',
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
|
|
||||||
import {useGate} from '#/lib/statsig/statsig'
|
|
||||||
import {useGeolocation} from '#/state/geolocation'
|
import {useGeolocation} from '#/state/geolocation'
|
||||||
|
|
||||||
export function useIsAgeAssuranceEnabled() {
|
export function useIsAgeAssuranceEnabled() {
|
||||||
const gate = useGate()
|
|
||||||
const {geolocation} = useGeolocation()
|
const {geolocation} = useGeolocation()
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
const enabled = gate('age_assurance')
|
return !!geolocation?.isAgeRestrictedGeo
|
||||||
return enabled && !!geolocation?.isAgeRestrictedGeo
|
}, [geolocation])
|
||||||
}, [geolocation, gate])
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user