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:
Eric Bailey 2023-11-09 17:14:51 -06:00 committed by GitHub
parent 664e7a91a9
commit 625cbc435f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 488 additions and 56 deletions

View file

@ -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}>