| null>(null);
-
- // Remember the latest callback
- useEffect(() => {
- savedCallback.current = callback;
- }, [callback]);
-
- // Reset the inactivity timer
- const resetTimer = useCallback(() => {
- if (timeoutRef.current) {
- clearTimeout(timeoutRef.current);
- }
-
- if (delay !== null && savedCallback.current) {
- timeoutRef.current = setTimeout(() => {
- // Fire callback once inactivity threshold reached if online
- if (savedCallback.current && isOnline()) {
- savedCallback.current();
- }
-
- // Schedule next run while still inactive
- resetTimer();
- }, delay);
- }
- }, [delay]);
-
- // Set up event listeners for user activity
- useEffect(() => {
- if (delay === null) {
- return;
- }
-
- // Add event listeners to track activity
- for (const event of events) {
- document.addEventListener(event, resetTimer, { passive: true });
- }
-
- // Start initial timer
- resetTimer();
-
- // Cleanup function
- return () => {
- if (timeoutRef.current) {
- clearTimeout(timeoutRef.current);
- }
-
- for (const event of events) {
- document.removeEventListener(event, resetTimer);
- }
- };
- }, [delay, resetTimer]);
-};
diff --git a/src/renderer/hooks/useNotifications.test.tsx b/src/renderer/hooks/useNotifications.test.tsx
index a8baf72f6..022e1272f 100644
--- a/src/renderer/hooks/useNotifications.test.tsx
+++ b/src/renderer/hooks/useNotifications.test.tsx
@@ -16,7 +16,6 @@ import {
import { useAccountsStore, useFiltersStore, useSettingsStore } from '../stores';
import type { AccountNotifications, Percentage } from '../types';
-import { FetchType } from '../types';
import { Errors } from '../utils/core/errors';
import * as logger from '../utils/core/logger';
@@ -182,7 +181,6 @@ describe('renderer/hooks/useNotifications.ts', () => {
getAllNotificationsMock.mockResolvedValue(mockSingleAccountNotifications);
useSettingsStore.setState({
- fetchType: FetchType.INTERVAL,
fetchInterval: 1000,
});
@@ -222,7 +220,6 @@ describe('renderer/hooks/useNotifications.ts', () => {
getAllNotificationsMock.mockResolvedValue(mockSingleAccountNotifications);
useSettingsStore.setState({
- fetchType: FetchType.INTERVAL,
fetchInterval: 1000,
});
diff --git a/src/renderer/hooks/useNotifications.ts b/src/renderer/hooks/useNotifications.ts
index 83aa849f9..72ec490f4 100644
--- a/src/renderer/hooks/useNotifications.ts
+++ b/src/renderer/hooks/useNotifications.ts
@@ -7,7 +7,6 @@ import { useAccountsStore, useFiltersStore, useSettingsStore } from '../stores';
import {
type Account,
type AccountNotifications,
- FetchType,
type GitifyError,
type GitifyNotification,
type Status,
@@ -32,7 +31,6 @@ import { removeNotificationsForAccount } from '../utils/notifications/remove';
import { getNewNotifications } from '../utils/notifications/utils';
import { raiseSoundNotification } from '../utils/system/audio';
import { raiseNativeNotification } from '../utils/system/native';
-import { useInactivityTimer } from './timers/useInactivityTimer';
interface NotificationsState {
status: Status;
@@ -54,10 +52,10 @@ interface NotificationsState {
interface UseNotificationsOptions {
/**
- * Run the singleton side effects (sound/native alerts for new notifications,
- * inactivity-based refetching, and interval/focus/reconnect polling). Only
- * the app-level effects host should enable this; all other consumers share
- * the query cache without them.
+ * Run the singleton side effects (sound/native alerts for new notifications
+ * and interval/focus/reconnect polling). Only the app-level effects host
+ * should enable this; all other consumers share the query cache without
+ * them.
*
* Polling is owned by the singleton host because TanStack Query schedules
* `refetchInterval` per mounted observer, not per query. Every consumer
@@ -98,7 +96,6 @@ export const useNotifications = ({
// Setting store values
const fetchReadNotifications = useSettingsStore((s) => s.fetchReadNotifications);
const fetchParticipatingNotifications = useSettingsStore((s) => s.participating);
- const fetchType = useSettingsStore((s) => s.fetchType);
const fetchIntervalMs = useSettingsStore((s) => s.fetchInterval);
const markAsDoneOnUnsubscribe = useSettingsStore((s) => s.markAsDoneOnUnsubscribe);
const playSoundNewNotifications = useSettingsStore((s) => s.playSound);
@@ -162,21 +159,12 @@ export const useNotifications = ({
// Only the singleton side-effects host polls. Other consumers share the
// cached data and would otherwise each schedule their own refetch timer.
- refetchInterval: withSideEffects && fetchType === FetchType.INTERVAL ? fetchIntervalMs : false,
+ refetchInterval: withSideEffects ? fetchIntervalMs : false,
refetchOnMount: withSideEffects,
refetchOnReconnect: withSideEffects,
refetchOnWindowFocus: withSideEffects,
});
- // Inactivity-based fetching re-fetches once the user has been idle for the
- // configured interval, instead of polling on a fixed schedule.
- useInactivityTimer(
- () => {
- refetch();
- },
- withSideEffects && fetchType === FetchType.INACTIVITY ? fetchIntervalMs : null,
- );
-
const notificationCount = getNotificationCount(notifications);
const unreadNotificationCount = getUnreadNotificationCount(notifications);
diff --git a/src/renderer/routes/__snapshots__/Settings.test.tsx.snap b/src/renderer/routes/__snapshots__/Settings.test.tsx.snap
index dcb7a8dc1..d1bbc7900 100644
--- a/src/renderer/routes/__snapshots__/Settings.test.tsx.snap
+++ b/src/renderer/routes/__snapshots__/Settings.test.tsx.snap
@@ -717,101 +717,6 @@ exports[`renderer/routes/Settings.tsx > should render itself & its children 1`]
-
-
-
-
-
-
-
-
-
-
-
-
should render itself & its children 1`]
data-wrap="nowrap"
>