fix: targeted sync after event changes - only refresh affected provider

Instead of force-refreshing all calendar providers after create/update/delete,
now only the specific connection that owns the modified calendar is refreshed.
This significantly speeds up recurring event operations when multiple
providers are connected.

v1.74.6

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mARTin 2026-03-25 13:05:39 +01:00
parent 245fed5f81
commit e4c1208b29
2 changed files with 18 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "my-weekly-todo-list", "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", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -2563,7 +2563,16 @@ export default function WeeklyView() {
const workingHoursEnd = endHour; const workingHoursEnd = endHour;
// Fetch calendar events // 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(); startSync();
setIsFetchingCalendar(true); setIsFetchingCalendar(true);
try { try {
@ -2578,6 +2587,7 @@ export default function WeeklyView() {
currentWeekStart.getTime() + 14 * 24 * 60 * 60 * 1000, currentWeekStart.getTime() + 14 * 24 * 60 * 60 * 1000,
).toISOString(), ).toISOString(),
forceRefresh, forceRefresh,
...(connectionId ? { connectionId } : {}),
}), }),
}); });
@ -2689,8 +2699,9 @@ export default function WeeklyView() {
return [...prev, frontendEvent]; return [...prev, frontendEvent];
}); });
} }
// Force refresh to get canonical state from providers // Force refresh only the affected provider
await fetchCalendarEvents(true); const connId = getConnectionIdForCalendar(eventData.calendarId);
await fetchCalendarEvents(true, connId);
} catch (error: any) { } catch (error: any) {
console.error("Error saving event:", error); console.error("Error saving event:", error);
if (error.name === "AbortError") { if (error.name === "AbortError") {
@ -2756,8 +2767,9 @@ export default function WeeklyView() {
e.id !== eventId && e.recurringEventId !== seriesId && e.id !== seriesId e.id !== eventId && e.recurringEventId !== seriesId && e.id !== seriesId
)); ));
} }
// Force refresh to get canonical state from providers // Force refresh only the affected provider
await fetchCalendarEvents(true); const connId = getConnectionIdForCalendar(calendarId);
await fetchCalendarEvents(true, connId);
} catch (error) { } catch (error) {
console.error("Error deleting event:", error); console.error("Error deleting event:", error);
throw error; throw error;