From 5d391fa4e01859578e18dfe336ebfb0056442766 Mon Sep 17 00:00:00 2001 From: MSomnium Studios <70982507+ArielLeyva@users.noreply.github.com> Date: Mon, 6 Oct 2025 10:31:08 -0400 Subject: [PATCH] Update the safeSetTimeout function to pass the test --- frontend/src/api/utils.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/src/api/utils.ts b/frontend/src/api/utils.ts index 78a6bfa7..f21fbe38 100644 --- a/frontend/src/api/utils.ts +++ b/frontend/src/api/utils.ts @@ -95,19 +95,17 @@ export function createURL(endpoint: string, searchParams = {}): string { export function setSafeTimeout(callback: () => void, delay: number): number { const MAX_DELAY = 86_400_000; let remaining = delay; - let timerId: number; - function scheduleNext() { + function scheduleNext(): number { if (remaining <= MAX_DELAY) { - timerId = window.setTimeout(callback, remaining); + return window.setTimeout(callback, remaining); } else { - timerId = window.setTimeout(() => { + return window.setTimeout(() => { remaining -= MAX_DELAY; scheduleNext(); }, MAX_DELAY); } } - scheduleNext(); - return timerId; + return scheduleNext(); }