[Session] Code cleanup (#3854)

* Split utils into files

* Move reducer to another file

* Write types explicitly

* Remove unnnecessary check

* Move things around a bit

* Move more stuff into agent factories

* Move more stuff into agent

* Fix gates await

* Clarify comments

* Enforce more via types

* Nit

* initSession -> resumeSession

* Protect against races

* Make agent opaque to reducer

* Check using plain condition
This commit is contained in:
dan 2024-05-08 03:30:55 +01:00 committed by GitHub
parent 4fe5a869c3
commit 0910525e2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 554 additions and 503 deletions

View file

@ -26,7 +26,7 @@ export const ChooseAccountForm = ({
const {track, screen} = useAnalytics()
const {_} = useLingui()
const {currentAccount} = useSession()
const {initSession} = useSessionApi()
const {resumeSession} = useSessionApi()
const {setShowLoggedOut} = useLoggedOutViewControls()
React.useEffect(() => {
@ -51,7 +51,7 @@ export const ChooseAccountForm = ({
}
try {
setPendingDid(account.did)
await initSession(account)
await resumeSession(account)
logEvent('account:loggedIn', {
logContext: 'ChooseAccountForm',
withPassword: false,
@ -71,7 +71,7 @@ export const ChooseAccountForm = ({
[
currentAccount,
track,
initSession,
resumeSession,
pendingDid,
onSelectAccount,
setShowLoggedOut,