From 65857791221cc14a19ba234f3ffc45c90711a0f9 Mon Sep 17 00:00:00 2001 From: Andrea Rampin Date: Wed, 31 Jan 2024 13:20:00 +1100 Subject: [PATCH] fix: [NOJIRA] increase REFRESH_BALANCE_INTERVAL_MS (#1430) --- .../widgets-lib/src/lib/hooks/useBalance.ts | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/packages/checkout/widgets-lib/src/lib/hooks/useBalance.ts b/packages/checkout/widgets-lib/src/lib/hooks/useBalance.ts index 14b4f2d813..1c07aec193 100644 --- a/packages/checkout/widgets-lib/src/lib/hooks/useBalance.ts +++ b/packages/checkout/widgets-lib/src/lib/hooks/useBalance.ts @@ -1,11 +1,11 @@ -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useState } from 'react'; import { Checkout, GetBalanceResult } from '@imtbl/checkout-sdk'; import { Web3Provider } from '@ethersproject/providers'; import { getTokenBalances } from '../../widgets/wallet/functions/tokenBalances'; import { DEFAULT_BALANCE_RETRY_POLICY } from '../constants'; import { useInterval } from './useInterval'; -const REFRESH_BALANCE_INTERVAL_MS = 10000; +const REFRESH_BALANCE_INTERVAL_MS = 30000; // 30 seconds -- keep app less chatty export interface UseBalanceParams { checkout: Checkout | undefined; @@ -58,18 +58,8 @@ export const useBalance = ({ } } }, [checkout, provider]); - useInterval(() => refreshBalances(true), REFRESH_BALANCE_INTERVAL_MS); - // Listen for window focus event to refresh after a potential interaction with a wallet - useEffect(() => { - const handleFocus = () => { - refreshBalances(true); - }; - window.addEventListener('focus', handleFocus); - return () => { - window.removeEventListener('focus', handleFocus); - }; - }, [refreshBalances]); + useInterval(() => refreshBalances(true), REFRESH_BALANCE_INTERVAL_MS); return { balancesLoading,