maybe fix

This commit is contained in:
Hailey
2024-07-13 12:01:41 -07:00
parent 0c09fdcfe3
commit 5fac41b2a4
+12 -12
View File
@@ -43,6 +43,7 @@ export type Action =
} }
| { | {
type: 'logged-out' type: 'logged-out'
accountDid: string
} }
| { | {
type: 'synced-accounts' type: 'synced-accounts'
@@ -143,21 +144,20 @@ let reducer = (state: State, action: Action): State => {
} }
} }
case 'logged-out': { case 'logged-out': {
//Fetch the account ID that the user signed out from
const {accountDid} = action const {accountDid} = action
//Find the account for which the tokens need to be cleared
const loggedOutAccount = state.accounts.filter(a => a.did === accountDid)
//Clear the tokens for the account that the user signed out from
loggedOutAccount.accessJwt = undefined
loggedOutAccount.refreshJwt = undefined
return { return {
//Return all the accounts. The other accounts remain unchanged, so the user will accounts: state.accounts.map(a => {
//stay signed in on them. if (a.did === accountDid) {
accounts: state.accounts return {
})), ...a,
accessJwt: undefined,
refreshJwt: undefined,
}
} else {
return a
}
}),
currentAgentState: createPublicAgentState(), currentAgentState: createPublicAgentState(),
needsPersist: true, needsPersist: true,
} }