Complete policy update after signup
This commit is contained in:
@@ -48,6 +48,7 @@ export function usePolicyUpdateState() {
|
|||||||
completed: true,
|
completed: true,
|
||||||
data: undefined,
|
data: undefined,
|
||||||
})
|
})
|
||||||
|
setCompletedForDevice(true)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, [nux, save, variables, deviceStorage, debugOverride])
|
}, [nux, save, variables, deviceStorage, debugOverride])
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import {useCallback} from 'react'
|
||||||
|
|
||||||
|
import {useSaveNux} from '#/state/queries/nuxs'
|
||||||
|
import {ACTIVE_UPDATE_ID} from '#/components/PolicyUpdateOverlay/config'
|
||||||
|
import {device, useStorage} from '#/storage'
|
||||||
|
|
||||||
|
export function usePreemptivelyCompleteActivePolicyUpdate() {
|
||||||
|
const {mutate: save} = useSaveNux()
|
||||||
|
const [_completedForDevice, setCompletedForDevice] = useStorage(device, [
|
||||||
|
ACTIVE_UPDATE_ID,
|
||||||
|
])
|
||||||
|
|
||||||
|
return useCallback(() => {
|
||||||
|
save({
|
||||||
|
id: ACTIVE_UPDATE_ID,
|
||||||
|
completed: true,
|
||||||
|
data: undefined,
|
||||||
|
})
|
||||||
|
setCompletedForDevice(true)
|
||||||
|
}, [save, setCompletedForDevice])
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import {getAge} from '#/lib/strings/time'
|
|||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useSessionApi} from '#/state/session'
|
import {useSessionApi} from '#/state/session'
|
||||||
import {useOnboardingDispatch} from '#/state/shell'
|
import {useOnboardingDispatch} from '#/state/shell'
|
||||||
|
import {usePreemptivelyCompleteActivePolicyUpdate} from '#/components/PolicyUpdateOverlay/usePreemptivelyCompleteActivePolicyUpdate'
|
||||||
|
|
||||||
export type ServiceDescription = ComAtprotoServerDescribeServer.OutputSchema
|
export type ServiceDescription = ComAtprotoServerDescribeServer.OutputSchema
|
||||||
|
|
||||||
@@ -252,6 +253,8 @@ export function useSubmitSignup() {
|
|||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {createAccount} = useSessionApi()
|
const {createAccount} = useSessionApi()
|
||||||
const onboardingDispatch = useOnboardingDispatch()
|
const onboardingDispatch = useOnboardingDispatch()
|
||||||
|
const preemptivelyCompleteActivePolicyUpdate =
|
||||||
|
usePreemptivelyCompleteActivePolicyUpdate()
|
||||||
|
|
||||||
return useCallback(
|
return useCallback(
|
||||||
async (state: SignupState, dispatch: (action: SignupAction) => void) => {
|
async (state: SignupState, dispatch: (action: SignupAction) => void) => {
|
||||||
@@ -325,6 +328,12 @@ export function useSubmitSignup() {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks any active policy update as completed, since user just agreed
|
||||||
|
* to TOS/privacy during sign up
|
||||||
|
*/
|
||||||
|
preemptivelyCompleteActivePolicyUpdate()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Must happen last so that if the user has multiple tabs open and
|
* Must happen last so that if the user has multiple tabs open and
|
||||||
* createAccount fails, one tab is not stuck in onboarding — Eric
|
* createAccount fails, one tab is not stuck in onboarding — Eric
|
||||||
@@ -363,6 +372,11 @@ export function useSubmitSignup() {
|
|||||||
dispatch({type: 'setIsLoading', value: false})
|
dispatch({type: 'setIsLoading', value: false})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[_, onboardingDispatch, createAccount],
|
[
|
||||||
|
_,
|
||||||
|
onboardingDispatch,
|
||||||
|
createAccount,
|
||||||
|
preemptivelyCompleteActivePolicyUpdate,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user