Comments
This commit is contained in:
@@ -207,4 +207,3 @@ export const PUBLIC_APPVIEW_DID = 'did:web:api.bsky.app'
|
|||||||
export const PUBLIC_STAGING_APPVIEW_DID = 'did:web:api.staging.bsky.dev'
|
export const PUBLIC_STAGING_APPVIEW_DID = 'did:web:api.staging.bsky.dev'
|
||||||
|
|
||||||
export const DEV_ENV_APPVIEW = `http://localhost:2584` // always the same
|
export const DEV_ENV_APPVIEW = `http://localhost:2584` // always the same
|
||||||
export const DEV_ENV_APPVIEW_DID = `did:plc:zkrndrc5vqjfn32cr4qya7c5` // get this from `localhost:2581`
|
|
||||||
|
|||||||
@@ -16,20 +16,24 @@ import {useGeolocation} from '#/state/geolocation'
|
|||||||
import {useAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const logger = Logger.create(Logger.Context.AgeAssurance)
|
const logger = Logger.create(Logger.Context.AgeAssurance)
|
||||||
|
|
||||||
export const createAgeAssuranceQueryKey = (did: string) =>
|
export const createAgeAssuranceQueryKey = (did: string) =>
|
||||||
['ageAssurance', did] as const
|
['ageAssurance', did] as const
|
||||||
|
|
||||||
const DEFAULT_AGE_ASSURANCE_STATE: AppBskyUnspeccedDefs.AgeAssuranceState = {
|
const DEFAULT_AGE_ASSURANCE_STATE: AppBskyUnspeccedDefs.AgeAssuranceState = {
|
||||||
lastInitiatedAt: undefined,
|
lastInitiatedAt: undefined,
|
||||||
status: 'unknown',
|
status: 'unknown',
|
||||||
}
|
}
|
||||||
|
|
||||||
const AgeAssuranceContext = createContext<AgeAssuranceContextType>({
|
const AgeAssuranceContext = createContext<AgeAssuranceContextType>({
|
||||||
status: 'unknown',
|
status: 'unknown',
|
||||||
isReady: false,
|
isReady: false,
|
||||||
lastInitiatedAt: undefined,
|
lastInitiatedAt: undefined,
|
||||||
isAgeRestricted: false,
|
isAgeRestricted: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
|
const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
|
||||||
// @ts-ignore
|
// @ts-ignore can't be bothered to type this
|
||||||
refetch: () => Promise.resolve(),
|
refetch: () => Promise.resolve(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {useMutation, useQueryClient} from '@tanstack/react-query'
|
|||||||
import {wait} from '#/lib/async/wait'
|
import {wait} from '#/lib/async/wait'
|
||||||
import {
|
import {
|
||||||
// DEV_ENV_APPVIEW,
|
// DEV_ENV_APPVIEW,
|
||||||
// DEV_ENV_APPVIEW_DID,
|
|
||||||
PUBLIC_APPVIEW,
|
PUBLIC_APPVIEW,
|
||||||
PUBLIC_APPVIEW_DID,
|
PUBLIC_APPVIEW_DID,
|
||||||
} from '#/lib/constants'
|
} from '#/lib/constants'
|
||||||
@@ -21,9 +20,17 @@ import {useAgent} from '#/state/session'
|
|||||||
let APPVIEW = PUBLIC_APPVIEW
|
let APPVIEW = PUBLIC_APPVIEW
|
||||||
let APPVIEW_DID = PUBLIC_APPVIEW_DID
|
let APPVIEW_DID = PUBLIC_APPVIEW_DID
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Uncomment if using the local dev-env
|
||||||
|
*/
|
||||||
// if (__DEV__) {
|
// if (__DEV__) {
|
||||||
// APPVIEW = DEV_ENV_APPVIEW
|
// APPVIEW = DEV_ENV_APPVIEW
|
||||||
// APPVIEW_DID = DEV_ENV_APPVIEW_DID
|
// /*
|
||||||
|
// * IMPORTANT: you need to get this value from `http://localhost:2581`
|
||||||
|
// * introspection endpoint and updated in `constants`, since it changes
|
||||||
|
// * every time you run the dev-env.
|
||||||
|
// */
|
||||||
|
// APPVIEW_DID = ``
|
||||||
// }
|
// }
|
||||||
|
|
||||||
export function useInitAgeAssurance() {
|
export function useInitAgeAssurance() {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import EventEmitter from 'eventemitter3'
|
|||||||
|
|
||||||
import {networkRetry} from '#/lib/async/retry'
|
import {networkRetry} from '#/lib/async/retry'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {isWeb} from '#/platform/detection'
|
|
||||||
import {type Device, device} from '#/storage'
|
import {type Device, device} from '#/storage'
|
||||||
|
|
||||||
const events = new EventEmitter()
|
const events = new EventEmitter()
|
||||||
@@ -69,13 +68,6 @@ export function beginResolveGeolocation() {
|
|||||||
*/
|
*/
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
geolocationResolution = new Promise(y => y({success: true}))
|
geolocationResolution = new Promise(y => y({success: true}))
|
||||||
|
|
||||||
// use for debugging
|
|
||||||
// device.set(['geolocation'], {
|
|
||||||
// countryCode: "GB",
|
|
||||||
// isAgeRestrictedGeo: true,
|
|
||||||
// })
|
|
||||||
|
|
||||||
if (!device.get(['geolocation'])) {
|
if (!device.get(['geolocation'])) {
|
||||||
device.set(['geolocation'], DEFAULT_GEOLOCATION)
|
device.set(['geolocation'], DEFAULT_GEOLOCATION)
|
||||||
}
|
}
|
||||||
@@ -187,17 +179,3 @@ export function Provider({children}: {children: React.ReactNode}) {
|
|||||||
export function useGeolocation() {
|
export function useGeolocation() {
|
||||||
return React.useContext(context)
|
return React.useContext(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__DEV__ && isWeb) {
|
|
||||||
// @ts-ignore
|
|
||||||
window.setGeolocation = (geo: Device['geolocation']) => {
|
|
||||||
if (!geo?.countryCode || typeof geo?.isAgeRestrictedGeo !== 'boolean') {
|
|
||||||
throw new Error(
|
|
||||||
`Expected {countryCode: string, isAgeRestrictedGeo: boolean}`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
device.set(['geolocation'], geo)
|
|
||||||
emitGeolocationUpdate(geo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -137,7 +137,10 @@ export function usePostFeedQuery(
|
|||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
/**
|
/**
|
||||||
* Load bearing: we need to await AA state or risk FOUC.
|
* Load bearing: we need to await AA state or risk FOUC. This marginally
|
||||||
|
* delays feeds, but AA state is fetched immediately on load and is then
|
||||||
|
* available for the remainder of the session, so this delay only affects cold
|
||||||
|
* loads. -esb
|
||||||
*/
|
*/
|
||||||
const {isReady: isAgeAssuranceReady} = useAgeAssuranceContext()
|
const {isReady: isAgeAssuranceReady} = useAgeAssuranceContext()
|
||||||
const enabled =
|
const enabled =
|
||||||
|
|||||||
Reference in New Issue
Block a user