From afba19227785a7538cee4670e055d62768534b35 Mon Sep 17 00:00:00 2001 From: Micaela Estabillo Date: Wed, 23 Oct 2024 15:51:55 -0700 Subject: [PATCH] chore: replace hardcoded values with a constant --- ui/hooks/bridge/useCountdownTimer.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/hooks/bridge/useCountdownTimer.ts b/ui/hooks/bridge/useCountdownTimer.ts index f55e66c2b75d..112d35b33f6a 100644 --- a/ui/hooks/bridge/useCountdownTimer.ts +++ b/ui/hooks/bridge/useCountdownTimer.ts @@ -5,7 +5,15 @@ import { getBridgeQuotes } from '../../ducks/bridge/selectors'; // TODO: Remove restricted import // eslint-disable-next-line import/no-restricted-paths import { REFRESH_INTERVAL_MS } from '../../../app/scripts/controllers/bridge/constants'; +import { SECOND } from '../../../shared/constants/time'; +/** + * Custom hook that provides a countdown timer based on the last fetched quotes timestamp. + * + * This hook calculates the remaining time until the next refresh interval and updates every second. + * + * @returns The formatted remaining time in 'm:ss' format. + */ export const useCountdownTimer = () => { const [timeRemaining, setTimeRemaining] = useState(REFRESH_INTERVAL_MS); const { quotesLastFetchedMs } = useSelector(getBridgeQuotes); @@ -20,8 +28,8 @@ export const useCountdownTimer = () => { useEffect(() => { const interval = setInterval(() => { - setTimeRemaining(Math.max(0, timeRemaining - 1000)); - }, 1000); + setTimeRemaining(Math.max(0, timeRemaining - SECOND)); + }, SECOND); return () => clearInterval(interval); }, [timeRemaining]);