diff options
author | Eric Bailey <git@esb.lol> | 2025-08-07 14:55:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-07 14:55:19 -0500 |
commit | 11c9931fd2bc9db8a6e4e71ae04d71051f63191c (patch) | |
tree | ed2de0262a18a8971d23214009afa6bdc172f9c1 /src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts | |
parent | c0593e49792af987b0c7accd6301f235d132030f (diff) | |
download | voidsky-11c9931fd2bc9db8a6e4e71ae04d71051f63191c.tar.zst |
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
Diffstat (limited to 'src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts')
-rw-r--r-- | src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts b/src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts index 29d8afe06..32b948af9 100644 --- a/src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts +++ b/src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts @@ -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({ |