First pass at a session handler (#1850)
* First pass at a session handler * TODOs * Fix recursion * Couple more things * Add back resume session concept * Handle ready * Cleanup of initial loading states * Handle init failure * Cleanup * Remove account * Add updateCurrentAccount * Remove log * Cleanup * Integrate removeAccount * Add hasSession * Add to App.native, harden migration * Use effect to persist data
This commit is contained in:
parent
664e7a91a9
commit
625cbc435f
9 changed files with 488 additions and 56 deletions
|
@ -82,12 +82,16 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||
|
||||
React.useEffect(() => {
|
||||
return persisted.onUpdate(() => {
|
||||
dispatch({
|
||||
type: 'set',
|
||||
step: persisted.get('onboarding').step as OnboardingStep,
|
||||
})
|
||||
const next = persisted.get('onboarding').step
|
||||
// TODO we've introduced a footgun
|
||||
if (state.step !== next) {
|
||||
dispatch({
|
||||
type: 'set',
|
||||
step: persisted.get('onboarding').step as OnboardingStep,
|
||||
})
|
||||
}
|
||||
})
|
||||
}, [dispatch])
|
||||
}, [state, dispatch])
|
||||
|
||||
return (
|
||||
<stateContext.Provider value={state}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue