diff --git a/dapp/src/hooks/sdk/useInitDataFromSdk.ts b/dapp/src/hooks/sdk/useInitDataFromSdk.ts index ce82aeda7..ab7f36c13 100644 --- a/dapp/src/hooks/sdk/useInitDataFromSdk.ts +++ b/dapp/src/hooks/sdk/useInitDataFromSdk.ts @@ -1,20 +1,25 @@ import { useEffect } from "react" +import { useInterval } from "@chakra-ui/react" +import { ONE_MINUTE_IN_SECONDS, ONE_SEC_IN_MILLISECONDS } from "#/constants" import { logPromiseFailure } from "#/utils" import { useWalletContext } from "../useWalletContext" import { useFetchBTCBalance } from "./useFetchBTCBalance" import { useFetchMinDepositAmount } from "./useFetchMinDepositAmount" import { useFetchDeposits } from "./useFetchDeposits" +const INTERVAL_TIME = ONE_SEC_IN_MILLISECONDS * ONE_MINUTE_IN_SECONDS * 30 + export function useInitDataFromSdk() { const { btcAccount } = useWalletContext() const fetchDeposits = useFetchDeposits() - useFetchBTCBalance() - useFetchMinDepositAmount() - useEffect(() => { if (btcAccount) { logPromiseFailure(fetchDeposits()) } }, [btcAccount, fetchDeposits]) + + useFetchBTCBalance() + useFetchMinDepositAmount() + useInterval(() => logPromiseFailure(fetchDeposits()), INTERVAL_TIME) }