Fix policy state (#8821)
* Mark completedForDevice prior to creating an account * Mark policies as completed after initial create account step
This commit is contained in:
@@ -20,6 +20,7 @@ import {Envelope_Stroke2_Corner0_Rounded as Envelope} from '#/components/icons/E
|
|||||||
import {Lock_Stroke2_Corner0_Rounded as Lock} from '#/components/icons/Lock'
|
import {Lock_Stroke2_Corner0_Rounded as Lock} from '#/components/icons/Lock'
|
||||||
import {Ticket_Stroke2_Corner0_Rounded as Ticket} from '#/components/icons/Ticket'
|
import {Ticket_Stroke2_Corner0_Rounded as Ticket} from '#/components/icons/Ticket'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
|
import {usePreemptivelyCompleteActivePolicyUpdate} from '#/components/PolicyUpdateOverlay/usePreemptivelyCompleteActivePolicyUpdate'
|
||||||
import {BackNextButtons} from '../BackNextButtons'
|
import {BackNextButtons} from '../BackNextButtons'
|
||||||
|
|
||||||
function sanitizeDate(date: Date): Date {
|
function sanitizeDate(date: Date): Date {
|
||||||
@@ -45,6 +46,8 @@ export function StepInfo({
|
|||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {state, dispatch} = useSignupContext()
|
const {state, dispatch} = useSignupContext()
|
||||||
|
const preemptivelyCompleteActivePolicyUpdate =
|
||||||
|
usePreemptivelyCompleteActivePolicyUpdate()
|
||||||
|
|
||||||
const inviteCodeValueRef = useRef<string>(state.inviteCode)
|
const inviteCodeValueRef = useRef<string>(state.inviteCode)
|
||||||
const emailValueRef = useRef<string>(state.email)
|
const emailValueRef = useRef<string>(state.email)
|
||||||
@@ -129,6 +132,7 @@ export function StepInfo({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preemptivelyCompleteActivePolicyUpdate()
|
||||||
dispatch({type: 'setInviteCode', value: inviteCode})
|
dispatch({type: 'setInviteCode', value: inviteCode})
|
||||||
dispatch({type: 'setEmail', value: email})
|
dispatch({type: 'setEmail', value: email})
|
||||||
dispatch({type: 'setPassword', value: password})
|
dispatch({type: 'setPassword', value: password})
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ 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
|
||||||
|
|
||||||
@@ -253,8 +252,6 @@ 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) => {
|
||||||
@@ -328,12 +325,6 @@ 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
|
||||||
@@ -372,11 +363,6 @@ 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