Fix missing rename to nextAccount

This commit is contained in:
ekzyis 2025-03-14 22:01:53 -05:00
parent 0d93c92e30
commit 54e7793668
2 changed files with 7 additions and 7 deletions

View File

@ -50,7 +50,7 @@ export const AccountProvider = ({ children }) => {
setAccounts(accounts => accounts.filter(({ id }) => id !== userId))
}, [])
const multiAuthSignout = useCallback(async () => {
const nextAccount = useCallback(async () => {
const { status } = await fetch('/api/next-account', { credentials: 'include' })
// if status is 302, this means the server was able to switch us to the next available account
// and the current account was simply removed from the list of available accounts including the corresponding JWT.
@ -66,8 +66,8 @@ export const AccountProvider = ({ children }) => {
}, [])
const value = useMemo(
() => ({ accounts, addAccount, removeAccount, meAnon, setMeAnon, multiAuthSignout }),
[accounts, addAccount, removeAccount, meAnon, setMeAnon, multiAuthSignout])
() => ({ accounts, addAccount, removeAccount, meAnon, setMeAnon, nextAccount }),
[accounts, addAccount, removeAccount, meAnon, setMeAnon, nextAccount])
return <AccountContext.Provider value={value}>{children}</AccountContext.Provider>
}

View File

@ -269,7 +269,7 @@ export default function LoginButton () {
function LogoutObstacle ({ onClose }) {
const { registration: swRegistration, togglePushSubscription } = useServiceWorker()
const { removeLocalWallets } = useWallets()
const { multiAuthSignout } = useAccounts()
const { nextAccount } = useAccounts()
const router = useRouter()
return (
@ -285,9 +285,9 @@ function LogoutObstacle ({ onClose }) {
</Button>
<Button
onClick={async () => {
const switchSuccess = await multiAuthSignout()
// only signout if multiAuth did not find a next available account
if (switchSuccess) {
const next = await nextAccount()
// only signout if we did not find a next account
if (next) {
onClose()
// reload whatever page we're on to avoid any bugs
router.reload()