diff --git a/packages/hooks/src/useAuthorize.ts b/packages/hooks/src/useAuthorize.ts index e90502d3a06b..ba29ad634669 100644 --- a/packages/hooks/src/useAuthorize.ts +++ b/packages/hooks/src/useAuthorize.ts @@ -1,4 +1,5 @@ import { useMemo } from 'react'; + import { useFetch } from '@deriv/api'; import { useStore } from '@deriv/stores'; @@ -10,7 +11,7 @@ const useAuthorize = (token?: string) => { const { data, ...rest } = useFetch('authorize', { payload: { authorize: token ?? current_token }, - options: { enabled: Boolean(token ?? current_token) }, + options: { enabled: Boolean(token ?? current_token), refetchOnWindowFocus: false }, }); // Add additional information to the authorize response. diff --git a/packages/hooks/src/useGetMFAccountStatus.ts b/packages/hooks/src/useGetMFAccountStatus.ts index fef6abd73a0a..f5a20a9c9df0 100644 --- a/packages/hooks/src/useGetMFAccountStatus.ts +++ b/packages/hooks/src/useGetMFAccountStatus.ts @@ -1,6 +1,7 @@ import { useEffect } from 'react'; + +import { ACCOUNT_BADGE_STATUS, routes } from '@deriv/shared'; import { useStore } from '@deriv/stores'; -import { ACCOUNT_BADGE_STATUS } from '@deriv/shared'; const useGetMFAccountStatus = () => { const { client } = useStore(); @@ -8,9 +9,11 @@ const useGetMFAccountStatus = () => { useEffect(() => { async function fetchData() { - await updateAccountStatus(); + if (is_logged_in && (!account_status || !window.location.pathname.startsWith(routes.trade))) + await updateAccountStatus(); } - if (is_logged_in) fetchData(); + fetchData(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const authentication = account_status?.authentication; const poi_status = authentication?.identity?.status; diff --git a/packages/hooks/src/usePaymentAgentTransferVisible.ts b/packages/hooks/src/usePaymentAgentTransferVisible.ts index 957dc08ab6f0..c8d13d4623c9 100644 --- a/packages/hooks/src/usePaymentAgentTransferVisible.ts +++ b/packages/hooks/src/usePaymentAgentTransferVisible.ts @@ -21,7 +21,9 @@ const usePaymentAgentTransferVisible = () => { checkAuthorize(); }, [is_authorize, is_logged_in]); - const { data, ...rest } = useFetch('get_settings', { options: { enabled: Boolean(is_websocket_authorized) } }); + const { data, ...rest } = useFetch('get_settings', { + options: { enabled: Boolean(is_websocket_authorized), refetchOnWindowFocus: false }, + }); const is_payment_agent_transfer_visible = Boolean(data?.get_settings?.is_authenticated_payment_agent); return {