enh
This commit is contained in:
parent
a09ae70b9f
commit
442e20c88a
2 changed files with 31 additions and 1 deletions
|
|
@ -72,6 +72,15 @@ export function useNeoRegionBootstrap(): void {
|
||||||
const [timedOut, setTimedOut] = useState(false)
|
const [timedOut, setTimedOut] = useState(false)
|
||||||
const [decisionTick, setDecisionTick] = useState(0)
|
const [decisionTick, setDecisionTick] = useState(0)
|
||||||
const lastAuthRef = useRef<boolean | null>(null)
|
const lastAuthRef = useRef<boolean | null>(null)
|
||||||
|
// The recovery poll below is torn down by the status flip it causes, so its
|
||||||
|
// own `cancelled` flag cannot guard the re-arm. This tracks a real unmount.
|
||||||
|
const mountedRef = useRef(true)
|
||||||
|
useEffect(() => {
|
||||||
|
mountedRef.current = true
|
||||||
|
return () => {
|
||||||
|
mountedRef.current = false
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
const addressesQuery = trpc.user.address.getUserAddresses.useQuery(undefined, {
|
const addressesQuery = trpc.user.address.getUserAddresses.useQuery(undefined, {
|
||||||
enabled: isAuthenticated,
|
enabled: isAuthenticated,
|
||||||
|
|
@ -347,7 +356,12 @@ export function useNeoRegionBootstrap(): void {
|
||||||
const usable = await probeLocation()
|
const usable = await probeLocation()
|
||||||
if (cancelled || !usable) return
|
if (cancelled || !usable) return
|
||||||
await refreshLocation()
|
await refreshLocation()
|
||||||
if (cancelled) return
|
// Do NOT gate this on `cancelled`: refresh() flips the status to
|
||||||
|
// 'locating', which makes locationIsUnusable false and runs this
|
||||||
|
// effect's cleanup while the fix is still being read. Only a real
|
||||||
|
// unmount (or a fix that still isn't there) should skip the re-arm.
|
||||||
|
if (!mountedRef.current) return
|
||||||
|
if (useLocationStore.getState().coords == null) return
|
||||||
decisionStarted = false
|
decisionStarted = false
|
||||||
useNeoRegionStore.getState().closeAddressFlow()
|
useNeoRegionStore.getState().closeAddressFlow()
|
||||||
setDecisionTick((tick) => tick + 1)
|
setDecisionTick((tick) => tick + 1)
|
||||||
|
|
|
||||||
|
|
@ -1248,3 +1248,19 @@ address flow reads that flag and shows a notice; previously the user only got
|
||||||
|
|
||||||
--- apps/user-ui/src/components/location/neo/NeoAddressFlow.tsx
|
--- apps/user-ui/src/components/location/neo/NeoAddressFlow.tsx
|
||||||
~ "Login to use saved addresses" -> "Sign in to use saved addresses"
|
~ "Login to use saved addresses" -> "Sign in to use saved addresses"
|
||||||
|
|
||||||
|
[2026-11-08 15:54:56 IST] location gate: recover after the user enables location.
|
||||||
|
|
||||||
|
The recovery poll awaited refreshLocation() and then re-armed the decision, but
|
||||||
|
refresh() flips the status to 'locating' first. That made locationIsUnusable
|
||||||
|
false, so this effect's cleanup ran (cancelled = true) while the fix was still
|
||||||
|
being read; the post-await `if (cancelled) return` then skipped the re-arm. The
|
||||||
|
notice disappeared (status granted) but decisionStarted stayed true, so no region
|
||||||
|
was ever published and the address flow stayed up.
|
||||||
|
|
||||||
|
--- apps/user-ui/src/hooks/useRegionNeo.ts
|
||||||
|
+ mountedRef so the re-arm is gated on the hook still being mounted, not on the
|
||||||
|
effect cleanup (which the status flip itself triggers)
|
||||||
|
+ after refreshLocation(), re-arm only when the fix actually arrived
|
||||||
|
(coords != null); a failed re-read leaves the poll subscribed
|
||||||
|
~ keep polling on failure (the effect re-subscribes when the status is unusable)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue