This commit is contained in:
Eric Bailey
2024-04-03 18:10:28 -05:00
parent de370bd2cc
commit e4e5bfb4c9
+7 -5
View File
@@ -192,11 +192,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
)
const setCurrentAccount = React.useCallback(
(account: SessionAccount, expired = false) => {
(account: SessionAccount) => {
setStateAndPersist(s => {
return {
...s,
currentAccount: expired ? undefined : account,
currentAccount: account,
accounts: [account, ...s.accounts.filter(a => a.did !== account.did)],
}
})
@@ -277,8 +277,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
({expired, refreshedAccount}) => {
if (expired) {
clearCurrentAccount()
} else {
setCurrentAccount(refreshedAccount)
}
setCurrentAccount(refreshedAccount, expired)
},
{networkErrorCallback: clearCurrentAccount},
),
@@ -325,8 +326,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
({expired, refreshedAccount}) => {
if (expired) {
clearCurrentAccount()
} else {
setCurrentAccount(refreshedAccount)
}
setCurrentAccount(refreshedAccount, expired)
},
{networkErrorCallback: clearCurrentAccount},
),
@@ -375,7 +377,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
clearCurrentAccount()
} else {
__globalAgent = agent
setCurrentAccount(refreshedAccount, expired)
setCurrentAccount(refreshedAccount)
}
},
{networkErrorCallback: clearCurrentAccount},