Skip to content

Commit f8c0367

Browse files
committed
chore: address PR comments
1 parent 94d30a1 commit f8c0367

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

ts/components/dialog/debug/components.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,11 @@ function AddDummyContactButton() {
229229
const [loading, setLoading] = useState(false);
230230
const [addedCount, setAddedCount] = useState(0);
231231

232-
const { data: contactsCount } = usePolling(fetchContactsCountAndUpdate, 1000);
232+
const { data: contactsCount } = usePolling(
233+
fetchContactsCountAndUpdate,
234+
1000,
235+
'AddDummyContactButton'
236+
);
233237

234238
return (
235239
<SessionButton

ts/hooks/usePolling.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useState } from 'react';
22

3-
export function usePolling<T>(fn: () => Promise<T>, delay: number) {
3+
export function usePolling<T>(fn: () => Promise<T>, pollInterval: number, identifier: string) {
44
const [data, setData] = useState<T | null>(null);
55
const [error, setError] = useState<Error | null>(null);
66

@@ -19,7 +19,7 @@ export function usePolling<T>(fn: () => Promise<T>, delay: number) {
1919
setError(null);
2020
}
2121
} catch (err) {
22-
window.log.warn('Polling error:', err);
22+
window.log.warn(`${identifier} polling error:`, err);
2323
if (isMounted) {
2424
setError(err as Error);
2525
}
@@ -32,13 +32,13 @@ export function usePolling<T>(fn: () => Promise<T>, delay: number) {
3232

3333
voidedExecute();
3434

35-
const interval = setInterval(voidedExecute, delay);
35+
const interval = setInterval(voidedExecute, pollInterval);
3636

3737
return () => {
3838
isMounted = false;
3939
clearInterval(interval);
4040
};
41-
}, [fn, delay]);
41+
}, [fn, pollInterval, identifier]);
4242

4343
return { data, error };
4444
}

0 commit comments

Comments
 (0)