Fix policy overlay logic (#8793)

* Only enable policy update overlay once the actual Overlay mounts (after onboarding and all that)

* Disable policy overlay in e2e

* Add comments

* Add extra insurance

* Rm log
This commit is contained in:
Eric Bailey
2025-08-07 14:55:19 -05:00
committed by GitHub
parent c0593e4979
commit 11c9931fd2
5 changed files with 80 additions and 17 deletions
@@ -11,13 +11,33 @@ export type PolicyUpdateState = {
complete: () => void
}
export function usePolicyUpdateState() {
export function usePolicyUpdateState({
enabled,
}: {
/**
* Used to skip the policy update overlay until we're actually ready to
* show it.
*/
enabled: boolean
}) {
const nux = useNux(ACTIVE_UPDATE_ID)
const {mutate: save, variables} = useSaveNux()
const deviceStorage = useStorage(device, [ACTIVE_UPDATE_ID])
const debugOverride =
!!useStorage(device, ['policyUpdateDebugOverride'])[0] && IS_DEV
return useMemo(() => {
/**
* If not enabled, then just return a completed state so the app functions
* as normal.
*/
if (!enabled) {
return {
completed: true,
complete() {},
}
}
const nuxIsReady = nux.status === 'ready'
const nuxIsCompleted = nux.nux?.completed === true
const nuxIsOptimisticallyCompleted = !!variables?.completed
@@ -59,7 +79,7 @@ export function usePolicyUpdateState() {
setCompletedForDevice(true)
},
}
}, [nux, save, variables, deviceStorage, debugOverride])
}, [enabled, nux, save, variables, deviceStorage, debugOverride])
}
export function computeCompletedState({