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:
parent
245fed5f81
commit
e4c1208b29
@ -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": {
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user