Cleanup
This commit is contained in:
@@ -192,11 +192,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const setCurrentAccount = React.useCallback(
|
const setCurrentAccount = React.useCallback(
|
||||||
(account: SessionAccount, expired = false) => {
|
(account: SessionAccount) => {
|
||||||
setStateAndPersist(s => {
|
setStateAndPersist(s => {
|
||||||
return {
|
return {
|
||||||
...s,
|
...s,
|
||||||
currentAccount: expired ? undefined : account,
|
currentAccount: account,
|
||||||
accounts: [account, ...s.accounts.filter(a => a.did !== account.did)],
|
accounts: [account, ...s.accounts.filter(a => a.did !== account.did)],
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -277,8 +277,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
({expired, refreshedAccount}) => {
|
({expired, refreshedAccount}) => {
|
||||||
if (expired) {
|
if (expired) {
|
||||||
clearCurrentAccount()
|
clearCurrentAccount()
|
||||||
|
} else {
|
||||||
|
setCurrentAccount(refreshedAccount)
|
||||||
}
|
}
|
||||||
setCurrentAccount(refreshedAccount, expired)
|
|
||||||
},
|
},
|
||||||
{networkErrorCallback: clearCurrentAccount},
|
{networkErrorCallback: clearCurrentAccount},
|
||||||
),
|
),
|
||||||
@@ -325,8 +326,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
({expired, refreshedAccount}) => {
|
({expired, refreshedAccount}) => {
|
||||||
if (expired) {
|
if (expired) {
|
||||||
clearCurrentAccount()
|
clearCurrentAccount()
|
||||||
|
} else {
|
||||||
|
setCurrentAccount(refreshedAccount)
|
||||||
}
|
}
|
||||||
setCurrentAccount(refreshedAccount, expired)
|
|
||||||
},
|
},
|
||||||
{networkErrorCallback: clearCurrentAccount},
|
{networkErrorCallback: clearCurrentAccount},
|
||||||
),
|
),
|
||||||
@@ -375,7 +377,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
clearCurrentAccount()
|
clearCurrentAccount()
|
||||||
} else {
|
} else {
|
||||||
__globalAgent = agent
|
__globalAgent = agent
|
||||||
setCurrentAccount(refreshedAccount, expired)
|
setCurrentAccount(refreshedAccount)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{networkErrorCallback: clearCurrentAccount},
|
{networkErrorCallback: clearCurrentAccount},
|
||||||
|
|||||||
Reference in New Issue
Block a user