Skip to content

Commit ede9b0b

Browse files
committed
feat: ability to set fetch type (interval or inactivity)
Signed-off-by: Adam Setch <[email protected]>
1 parent d6908fe commit ede9b0b

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/renderer/components/settings/NotificationSettings.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
3434
expect(updateSetting).toHaveBeenCalledWith('groupBy', 'DATE');
3535
});
3636

37+
it('should change the fetchType radio group', async () => {
38+
await act(async () => {
39+
render(
40+
<AppContext.Provider
41+
value={{
42+
auth: mockAuth,
43+
settings: mockSettings,
44+
updateSetting,
45+
}}
46+
>
47+
<NotificationSettings />
48+
</AppContext.Provider>,
49+
);
50+
});
51+
52+
await userEvent.click(screen.getByTestId('radio-fetchType-inactivity'));
53+
54+
expect(updateSetting).toHaveBeenCalledTimes(1);
55+
expect(updateSetting).toHaveBeenCalledWith('fetchType', 'INACTIVITY');
56+
});
57+
3758
it('should toggle the fetchAllNotifications checkbox', async () => {
3859
await act(async () => {
3960
render(

src/renderer/hooks/timers/useInactivityTimer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export const useInactivityTimer = (callback: () => void, delay: number) => {
3939
}
4040

4141
// Add event listeners to track activity
42-
events.forEach((event) => {
42+
for (const event of events) {
4343
document.addEventListener(event, resetTimer, { passive: true });
44-
});
44+
}
4545

4646
// Start initial timer
4747
resetTimer();
@@ -52,9 +52,9 @@ export const useInactivityTimer = (callback: () => void, delay: number) => {
5252
clearTimeout(timeoutRef.current);
5353
}
5454

55-
events.forEach((event) => {
55+
for (const event of events) {
5656
document.removeEventListener(event, resetTimer);
57-
});
57+
}
5858
};
5959
}, [delay, resetTimer]);
6060
};

0 commit comments

Comments
 (0)