From fc533d8e119fd7e26a122f27c4866d172e2e4d51 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 10 Sep 2022 20:51:21 +0530 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Alois Klink --- src/lib/util/state.ts | 2 +- src/lib/util/stats.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/util/state.ts b/src/lib/util/state.ts index a4940f45..81df4a72 100644 --- a/src/lib/util/state.ts +++ b/src/lib/util/state.ts @@ -165,7 +165,7 @@ export const toggleDarkTheme = (dark: boolean): void => { let urlDebounce: number; export const initURLSubscription = (): void => { stateStore.subscribe(({ serialized }) => { - clearInterval(urlDebounce); + clearTimeout(urlDebounce); urlDebounce = window.setTimeout(() => { history.replaceState(undefined, undefined, `#${serialized}`); }, 250); diff --git a/src/lib/util/stats.ts b/src/lib/util/stats.ts index 8cafc005..2ee252b9 100644 --- a/src/lib/util/stats.ts +++ b/src/lib/util/stats.ts @@ -53,7 +53,7 @@ const timeouts: Record = {}; export const logEvent = (name: string, data?: unknown): void => { if (analytics) { const key = data ? JSON.stringify({ name, data }) : name; - clearInterval(timeouts[key]); + clearTimeout(timeouts[key]); timeouts[key] = window.setTimeout(() => { void analytics.track(name, data); }, 5000);