From eb4a368ad12c90944915d971d82ac9aa25cc3289 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Thu, 16 Feb 2023 15:39:43 +0700 Subject: [PATCH] Revert "fix(#274): off check new device option" This reverts commit 6dad0f375840d17ddb206a3c8879ebd576deb959. --- src/features/AuthStore/hooks/useAuth.tsx | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/features/AuthStore/hooks/useAuth.tsx b/src/features/AuthStore/hooks/useAuth.tsx index 4d0a4542..aa91df65 100644 --- a/src/features/AuthStore/hooks/useAuth.tsx +++ b/src/features/AuthStore/hooks/useAuth.tsx @@ -36,7 +36,6 @@ import { queryParamStorage } from 'features/QueryParamsStorage' import { getUserInfo, UserInfo } from 'requests/getUserInfo' import { checkDevice, FailedResponse } from 'requests/checkDevice' -// eslint-disable-next-line import { getClientSettings, needCheckNewDeviсe } from '../helpers' import { getTokenVirtualUser } from '../../../requests' @@ -180,7 +179,6 @@ export const useAuth = () => { }) }, [logout, userManager]) - // eslint-disable-next-line const checkNewDevice = useCallback(async () => { const loadedUser = await userManager.getUser() if (!loadedUser) return @@ -190,18 +188,18 @@ export const useAuth = () => { }) }, [reChekNewDevice, userManager]) - // 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