fix(check device): return check device

pull/132/head
Andrei Dekterev 3 years ago
parent b80ced0877
commit e50e3c1d8c
  1. 28
      src/features/AuthStore/hooks/useAuth.tsx

@ -42,7 +42,6 @@ import {
} from 'requests'
import { userManager } from '../config'
// eslint-disable-next-line
import { needCheckNewDeviсe } from '../helpers'
export const useAuth = () => {
@ -220,7 +219,6 @@ export const useAuth = () => {
})
}, [logout])
// eslint-disable-next-line
const checkNewDevice = useCallback(async () => {
const loadedUser = await userManager.getUser()
if (!loadedUser) return
@ -230,18 +228,18 @@ export const useAuth = () => {
})
}, [reChekNewDevice])
// useEffect(() => {
// if (!needCheckNewDeviсe && !user) return undefined
// const startCheckDevice = setInterval(checkNewDevice, 20000)
// isNewDeviceLogin && clearInterval(startCheckDevice)
// return () => clearInterval(startCheckDevice)
//
// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, [
// checkNewDevice,
// isNewDeviceLogin,
// setIsNewDeviceLogin,
// ])
useEffect(() => {
if (!needCheckNewDeviсe && !user) return undefined
const startCheckDevice = setInterval(checkNewDevice, 20000)
isNewDeviceLogin && clearInterval(startCheckDevice)
return () => clearInterval(startCheckDevice)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
checkNewDevice,
isNewDeviceLogin,
setIsNewDeviceLogin,
])
useEffect(() => {
// попытаемся обновить токен используя refresh_token
@ -290,7 +288,7 @@ export const useAuth = () => {
}, [changeLang])
useEffect(() => {
fetchUserInfo()
readToken() && fetchUserInfo()
}, [fetchUserInfo, user])
const auth = useMemo(() => ({

Loading…
Cancel
Save