diff --git a/package.json b/package.json index 5c8629f..d0785e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "my-weekly-todo-list", - "version": "1.68.0", + "version": "1.68.1", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "main": "index.js", "scripts": { diff --git a/src/components/WeeklyView.tsx b/src/components/WeeklyView.tsx index 72e95d5..4ad7498 100644 --- a/src/components/WeeklyView.tsx +++ b/src/components/WeeklyView.tsx @@ -2830,7 +2830,7 @@ export default function WeeklyView() { } }, []); - // Periodic pull-sync from Google Tasks (every 2 minutes) + // Periodic pull-sync from external task providers (every 15 minutes) useEffect(() => { if (!session) return; const interval = setInterval( @@ -2843,16 +2843,14 @@ export default function WeeklyView() { console.log( `[SYNC] Pulled ${data.updated} updates, ${data.deleted} deletions, ${data.created || 0} new tasks`, ); - fetchTasks(); // Reload to reflect changes + fetchTasks(); } } } catch (e) { console.error("[SYNC] Task sync error:", e); - setSyncError("Task sync failed"); - setTimeout(() => setSyncError(null), 10000); } }, - 5 * 60 * 1000, + 15 * 60 * 1000, ); return () => clearInterval(interval); }, [session]); @@ -2895,7 +2893,7 @@ export default function WeeklyView() { }; }, [session]); - // Periodic background calendar cache refresh (every 2 minutes) + // Periodic background calendar cache refresh (every 15 minutes) useEffect(() => { if (!session) return; const interval = setInterval( @@ -2912,23 +2910,20 @@ export default function WeeklyView() { timeMax: new Date( now.getTime() + 14 * 24 * 60 * 60 * 1000, ).toISOString(), - forceRefresh: true, }), }); if (res.ok) { const data = await res.json(); - if (data.queued > 0 || data.refreshed > 0) { - // Cache was refreshed; re-fetch events after delay - setTimeout(() => fetchCalendarEvents(), 8000); + if (data.queued > 0) { + // Stale connections are refreshing in background; re-read cache after delay + setTimeout(() => fetchCalendarEvents(), 10000); } } } catch (e) { console.error("[SYNC] Calendar sync error:", e); - setSyncError("Calendar sync failed"); - setTimeout(() => setSyncError(null), 10000); } }, - 2 * 60 * 1000, + 15 * 60 * 1000, ); return () => clearInterval(interval); }, [session, fetchCalendarEvents]); diff --git a/src/lib/calendar-cache.ts b/src/lib/calendar-cache.ts index 8928639..cda732c 100644 --- a/src/lib/calendar-cache.ts +++ b/src/lib/calendar-cache.ts @@ -4,7 +4,7 @@ import { prisma } from './prisma'; import { getCalendarEvents, CalendarEvent, CalendarConnection } from './calendar-events'; -const STALE_THRESHOLD_MS = 2 * 60 * 1000; // 2 minutes — match background sync interval +const STALE_THRESHOLD_MS = 15 * 60 * 1000; // 15 minutes — reduce API calls to providers /** * Get the Monday (start of ISO week) for a given date.