[AAv2] Improve minimum age handling (#9650)

* Improve miminum age handling

* Update api sdk

* Fix bad import
This commit is contained in:
Eric Bailey
2026-01-08 15:36:26 -06:00
committed by GitHub
parent a1857d62bd
commit b3f775d1d8
11 changed files with 253 additions and 98 deletions
+12 -6
View File
@@ -5,14 +5,20 @@ import {type Geolocation} from '#/geolocation/types'
const localEnabled = false
export const enabled = IS_DEV && (localEnabled || aaDebug.geolocation)
export const geolocation: Geolocation = aaDebug.geolocation ?? {
countryCode: 'AU',
regionCode: undefined,
}
export const deviceGeolocation: Geolocation = aaDebug.deviceGeolocation ?? {
countryCode: 'AU',
regionCode: undefined,
countryCode: 'US',
regionCode: 'TX',
}
const deviceLocalEnabled = false
export const deviceGeolocation: Geolocation | undefined =
aaDebug.deviceGeolocation ||
(deviceLocalEnabled
? {
countryCode: 'US',
regionCode: 'TX',
}
: undefined)
export async function resolve<T>(data: T) {
await new Promise(y => setTimeout(y, 500)) // simulate network
return data
+7 -1
View File
@@ -46,7 +46,8 @@ const useForegroundPermissions = createPermissionHook({
})
export async function getDeviceGeolocation(): Promise<Geolocation> {
if (debug.enabled) return debug.resolve(debug.deviceGeolocation)
if (debug.enabled && debug.deviceGeolocation)
return debug.resolve(debug.deviceGeolocation)
try {
const geocode = await Location.getCurrentPositionAsync()
@@ -142,3 +143,8 @@ export function useSyncDeviceGeolocationOnStartup(
})
}, [status, sync])
}
export function useIsDeviceGeolocationGranted() {
const [status] = useForegroundPermissions()
return status?.granted === true
}
+4 -1
View File
@@ -12,7 +12,10 @@ import {type Geolocation} from '#/geolocation/types'
import {mergeGeolocations} from '#/geolocation/util'
import {device, useStorage} from '#/storage'
export {useRequestDeviceGeolocation} from '#/geolocation/device'
export {
useIsDeviceGeolocationGranted,
useRequestDeviceGeolocation,
} from '#/geolocation/device'
export {resolve} from '#/geolocation/service'
export * from '#/geolocation/types'