diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 3f2ba9b25b..3f0d499894 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -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 DEV_ENV_APPVIEW = `http://localhost:2584` // always the same -export const DEV_ENV_APPVIEW_DID = `did:plc:zkrndrc5vqjfn32cr4qya7c5` // get this from `localhost:2581` diff --git a/src/state/ageAssurance/index.tsx b/src/state/ageAssurance/index.tsx index 6c688d1b63..34bcf12234 100644 --- a/src/state/ageAssurance/index.tsx +++ b/src/state/ageAssurance/index.tsx @@ -16,20 +16,24 @@ import {useGeolocation} from '#/state/geolocation' import {useAgent} from '#/state/session' const logger = Logger.create(Logger.Context.AgeAssurance) + export const createAgeAssuranceQueryKey = (did: string) => ['ageAssurance', did] as const + const DEFAULT_AGE_ASSURANCE_STATE: AppBskyUnspeccedDefs.AgeAssuranceState = { lastInitiatedAt: undefined, status: 'unknown', } + const AgeAssuranceContext = createContext({ status: 'unknown', isReady: false, lastInitiatedAt: undefined, isAgeRestricted: false, }) + const AgeAssuranceAPIContext = createContext({ - // @ts-ignore + // @ts-ignore can't be bothered to type this refetch: () => Promise.resolve(), }) diff --git a/src/state/ageAssurance/useInitAgeAssurance.ts b/src/state/ageAssurance/useInitAgeAssurance.ts index 6210e37e0d..8776dd29cc 100644 --- a/src/state/ageAssurance/useInitAgeAssurance.ts +++ b/src/state/ageAssurance/useInitAgeAssurance.ts @@ -8,7 +8,6 @@ import {useMutation, useQueryClient} from '@tanstack/react-query' import {wait} from '#/lib/async/wait' import { // DEV_ENV_APPVIEW, - // DEV_ENV_APPVIEW_DID, PUBLIC_APPVIEW, PUBLIC_APPVIEW_DID, } from '#/lib/constants' @@ -21,9 +20,17 @@ import {useAgent} from '#/state/session' let APPVIEW = PUBLIC_APPVIEW let APPVIEW_DID = PUBLIC_APPVIEW_DID +/* + * Uncomment if using the local dev-env + */ // if (__DEV__) { // 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() { diff --git a/src/state/geolocation.tsx b/src/state/geolocation.tsx index e55986cb06..20b161ffe1 100644 --- a/src/state/geolocation.tsx +++ b/src/state/geolocation.tsx @@ -3,7 +3,6 @@ import EventEmitter from 'eventemitter3' import {networkRetry} from '#/lib/async/retry' import {logger} from '#/logger' -import {isWeb} from '#/platform/detection' import {type Device, device} from '#/storage' const events = new EventEmitter() @@ -69,13 +68,6 @@ export function beginResolveGeolocation() { */ if (__DEV__) { geolocationResolution = new Promise(y => y({success: true})) - - // use for debugging - // device.set(['geolocation'], { - // countryCode: "GB", - // isAgeRestrictedGeo: true, - // }) - if (!device.get(['geolocation'])) { device.set(['geolocation'], DEFAULT_GEOLOCATION) } @@ -187,17 +179,3 @@ export function Provider({children}: {children: React.ReactNode}) { export function useGeolocation() { 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) - } -} diff --git a/src/state/queries/post-feed.ts b/src/state/queries/post-feed.ts index 9738f53e5c..22e95fcd63 100644 --- a/src/state/queries/post-feed.ts +++ b/src/state/queries/post-feed.ts @@ -137,7 +137,10 @@ export function usePostFeedQuery( const moderationOpts = useModerationOpts() 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 enabled =