diff --git a/package.json b/package.json index 8cb054d..b09eca1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "my-weekly-todo-list", - "version": "1.74.5", + "version": "1.74.6", "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 0ee69d2..4351399 100644 --- a/src/components/WeeklyView.tsx +++ b/src/components/WeeklyView.tsx @@ -2563,7 +2563,16 @@ export default function WeeklyView() { const workingHoursEnd = endHour; // Fetch calendar events - const fetchCalendarEvents = useCallback(async (forceRefresh = false) => { + // Find connectionId for a given calendarId + const getConnectionIdForCalendar = useCallback((calId?: string) => { + if (!calId) return undefined; + const conn = connections.find((c: any) => + (c.calendars || []).some((cal: any) => cal.id === calId) + ); + return conn?.id; + }, [connections]); + + const fetchCalendarEvents = useCallback(async (forceRefresh = false, connectionId?: string) => { startSync(); setIsFetchingCalendar(true); try { @@ -2578,6 +2587,7 @@ export default function WeeklyView() { currentWeekStart.getTime() + 14 * 24 * 60 * 60 * 1000, ).toISOString(), forceRefresh, + ...(connectionId ? { connectionId } : {}), }), }); @@ -2689,8 +2699,9 @@ export default function WeeklyView() { return [...prev, frontendEvent]; }); } - // Force refresh to get canonical state from providers - await fetchCalendarEvents(true); + // Force refresh only the affected provider + const connId = getConnectionIdForCalendar(eventData.calendarId); + await fetchCalendarEvents(true, connId); } catch (error: any) { console.error("Error saving event:", error); if (error.name === "AbortError") { @@ -2756,8 +2767,9 @@ export default function WeeklyView() { e.id !== eventId && e.recurringEventId !== seriesId && e.id !== seriesId )); } - // Force refresh to get canonical state from providers - await fetchCalendarEvents(true); + // Force refresh only the affected provider + const connId = getConnectionIdForCalendar(calendarId); + await fetchCalendarEvents(true, connId); } catch (error) { console.error("Error deleting event:", error); throw error;