[Session] Remove global agent (#3852)

* Remove logs and outdated comments

* Move side effect upwards

* Pull refreshedAccount next to usage

* Simplify account refresh logic

* Extract setupPublicAgentState()

* Collapse setStates into one

* Ignore events from stale agents

* Use agent from state

* Remove clearCurrentAccount

* Move state to a reducer

* Remove global agent

* Fix stale agent reference in create flow

* Proceed to onboarding even if setting date fails

---------

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
dan 2024-05-08 03:10:03 +01:00 committed by GitHub
parent 31a8356aef
commit 0c41b3188a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 265 additions and 360 deletions

View file

@ -31,7 +31,7 @@ export function Component({}: {}) {
const theme = useTheme()
const {currentAccount} = useSession()
const {getAgent} = useAgent()
const {clearCurrentAccount, removeAccount} = useSessionApi()
const {removeAccount} = useSessionApi()
const {_} = useLingui()
const {closeModal} = useModalControls()
const {isMobile} = useWebMediaQueries()
@ -69,7 +69,6 @@ export function Component({}: {}) {
Toast.show(_(msg`Your account has been deleted`))
resetToTab('HomeTab')
removeAccount(currentAccount)
clearCurrentAccount()
closeModal()
} catch (e: any) {
setError(cleanError(e))