From 3d1bd8af4f6b61231316d7daf2332990339ff0fa Mon Sep 17 00:00:00 2001 From: Farber Denis Date: Wed, 24 Aug 2022 19:05:00 +0300 Subject: [PATCH] fix(#ott2714): min fix --- src/features/App/index.tsx | 6 +++--- src/features/AuthStore/hooks/useAuth.tsx | 7 +++++-- src/helpers/isMatchPage/index.tsx | 8 ++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/features/App/index.tsx b/src/features/App/index.tsx index f034ae04..190e4ea6 100644 --- a/src/features/App/index.tsx +++ b/src/features/App/index.tsx @@ -8,7 +8,7 @@ import { client } from 'config/clients' import { matomoInstance } from 'config/matomo' import { setClientTitleAndDescription } from 'helpers/setClientHeads' -import { isMatchPage } from 'helpers/isMatchPage' +import { isMatchPage, isMatchPageRFEF } from 'helpers/isMatchPage' import { GlobalStores } from 'features/GlobalStores' import { useAuthStore } from 'features/AuthStore' @@ -25,8 +25,8 @@ setClientTitleAndDescription(client.title, client.description) const Main = () => { const { loadingUser, user } = useAuthStore() - if (!user && isMatchPage() && !window.location.href.includes('1rfef')) return - if (!user && window.location.href.includes('1rfef')) return + if (!user && isMatchPage() && !isMatchPageRFEF() && !window.location.href.includes('1rfef')) return + if (!user && isMatchPageRFEF() && !isMatchPage() && window.location.href.includes('1rfef')) return // юзер считывается из localstorage или // access_token токен истек и запрашивается новый diff --git a/src/features/AuthStore/hooks/useAuth.tsx b/src/features/AuthStore/hooks/useAuth.tsx index fbd080a1..f9387124 100644 --- a/src/features/AuthStore/hooks/useAuth.tsx +++ b/src/features/AuthStore/hooks/useAuth.tsx @@ -18,7 +18,7 @@ import { } from 'helpers/languageUrlParam' import { writeToken, removeToken } from 'helpers/token' import { setCookie, removeCookie } from 'helpers/cookie' -import { isMatchPage } from 'helpers/isMatchPage' +import { isMatchPage, isMatchPageRFEF } from 'helpers/isMatchPage' import { useLocalStore, useToggle } from 'hooks' @@ -124,9 +124,12 @@ export const useAuth = () => { signinRedirectCallback() } else { checkUser().catch(() => { - if (!isMatchPage()) { + if (!isMatchPage() && !isMatchPageRFEF()) { login() } + // if (!isMatchPageRFEF()) { + // login() + // } if (history.location.pathname === '/') { setSearch(history.location.search) } diff --git a/src/helpers/isMatchPage/index.tsx b/src/helpers/isMatchPage/index.tsx index 3a8729cc..8fd23db0 100644 --- a/src/helpers/isMatchPage/index.tsx +++ b/src/helpers/isMatchPage/index.tsx @@ -8,3 +8,11 @@ export const isMatchPage = () => { return pageType === 'matches' && !isUndefined(matchId) } + +export const isMatchPageRFEF = () => { + const splitPath = window.location.pathname.split('/') + const pageType = splitPath[3] + const matchId = toNumber(splitPath[3]) + + return pageType === 'matches' && !isUndefined(matchId) +}