diff --git a/src/components/PolicyUpdateOverlay/context.tsx b/src/components/PolicyUpdateOverlay/context.tsx index 1cd069224b..ef8ad7f83b 100644 --- a/src/components/PolicyUpdateOverlay/context.tsx +++ b/src/components/PolicyUpdateOverlay/context.tsx @@ -20,6 +20,11 @@ const Context = createContext<{ completed: true, complete: () => {}, }, + /** + * Although our data will be ready to go when the app shell mounts, we don't + * want to show the overlay until we actually render it, which happens after + * sigin/signup/onboarding in `createNativeStackNavigatorWithAuth`. + */ setIsReadyToShowOverlay: () => {}, }) diff --git a/src/components/PolicyUpdateOverlay/index.tsx b/src/components/PolicyUpdateOverlay/index.tsx index c8bd694c43..f30da4334c 100644 --- a/src/components/PolicyUpdateOverlay/index.tsx +++ b/src/components/PolicyUpdateOverlay/index.tsx @@ -16,6 +16,9 @@ export function PolicyUpdateOverlay() { const {state, setIsReadyToShowOverlay} = usePolicyUpdateContext() useEffect(() => { + /** + * Tell the context that we are ready to show the overlay. + */ setIsReadyToShowOverlay() }, [setIsReadyToShowOverlay]) diff --git a/src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts b/src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts index 2ac7be96e0..32b948af9d 100644 --- a/src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts +++ b/src/components/PolicyUpdateOverlay/usePolicyUpdateState.ts @@ -11,13 +11,26 @@ export type PolicyUpdateState = { complete: () => void } -export function usePolicyUpdateState({enabled}: {enabled: boolean}) { +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,