Add comments
This commit is contained in:
@@ -20,6 +20,11 @@ const Context = createContext<{
|
|||||||
completed: true,
|
completed: true,
|
||||||
complete: () => {},
|
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: () => {},
|
setIsReadyToShowOverlay: () => {},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ export function PolicyUpdateOverlay() {
|
|||||||
const {state, setIsReadyToShowOverlay} = usePolicyUpdateContext()
|
const {state, setIsReadyToShowOverlay} = usePolicyUpdateContext()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
/**
|
||||||
|
* Tell the context that we are ready to show the overlay.
|
||||||
|
*/
|
||||||
setIsReadyToShowOverlay()
|
setIsReadyToShowOverlay()
|
||||||
}, [setIsReadyToShowOverlay])
|
}, [setIsReadyToShowOverlay])
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,26 @@ export type PolicyUpdateState = {
|
|||||||
complete: () => void
|
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 nux = useNux(ACTIVE_UPDATE_ID)
|
||||||
const {mutate: save, variables} = useSaveNux()
|
const {mutate: save, variables} = useSaveNux()
|
||||||
const deviceStorage = useStorage(device, [ACTIVE_UPDATE_ID])
|
const deviceStorage = useStorage(device, [ACTIVE_UPDATE_ID])
|
||||||
const debugOverride =
|
const debugOverride =
|
||||||
!!useStorage(device, ['policyUpdateDebugOverride'])[0] && IS_DEV
|
!!useStorage(device, ['policyUpdateDebugOverride'])[0] && IS_DEV
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
|
/**
|
||||||
|
* If not enabled, then just return a completed state so the app functions
|
||||||
|
* as normal.
|
||||||
|
*/
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return {
|
return {
|
||||||
completed: true,
|
completed: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user