Skip to content

Commit

Permalink
reduce unnecessary log outs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsladerman committed Sep 17, 2024
1 parent e412860 commit 1569ec1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions assets/src/components/login/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation, useQuery } from '@apollo/client'
import { ApolloError, useMutation, useQuery } from '@apollo/client'
import { Button, LoopingLogo } from '@pluralsh/design-system'
import { WelcomeHeader } from 'components/utils/WelcomeHeader'
import { useMeQuery } from 'generated/graphql'
Expand Down Expand Up @@ -41,16 +41,18 @@ const setInputFocus = (ref: RefObject<any>) => {
})
}

function LoginError({ error }) {
function LoginError({ error }: { error: ApolloError | undefined }) {
useEffect(() => {
const to = setTimeout(() => {
wipeToken()
wipeRefreshToken()
window.location = '/login' as any as Location
}, 2000)
if (!error?.networkError) {
const to = setTimeout(() => {
wipeToken()
wipeRefreshToken()
window.location = '/login' as any as Location
}, 2000)

return () => clearTimeout(to)
}, [])
return () => clearTimeout(to)
}
}, [error?.networkError])

console.error('Login error:', error)

Expand Down

0 comments on commit 1569ec1

Please sign in to comment.