Merge pull request #1974 from stackernews/rename-to-next-account
Fix missing rename to nextAccount
This commit is contained in:
		
						commit
						53f6c34ee7
					
				@ -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>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user