fix: JSCalendar 2.0 recurrenceRule single-object compatibility 116

This commit is contained in:
Linus Rath
2026-03-31 00:11:04 +02:00
parent aaa283357e
commit 1cce5c3c8a
6 changed files with 986 additions and 146 deletions
+18 -1
View File
@@ -321,7 +321,24 @@ export const useCalendarStore = create<CalendarStore>()(
}
await client.updateCalendarEvent(realId, cleanUpdates, sendSchedulingMessages, targetAccountId);
set((state) => ({
events: state.events.map(e => e.id === id ? { ...e, ...cleanUpdates } : e),
events: state.events.map(e => {
if (e.id !== id) return e;
const merged = { ...e, ...cleanUpdates };
// When start changes, shift utcStart/utcEnd by the same delta so the
// event renders at the new position immediately (optimistic update).
if (cleanUpdates.start && e.start && e.utcStart) {
const oldStart = new Date(e.start).getTime();
const newStart = new Date(cleanUpdates.start).getTime();
const delta = newStart - oldStart;
if (delta !== 0) {
merged.utcStart = new Date(new Date(e.utcStart).getTime() + delta).toISOString();
if (e.utcEnd) {
merged.utcEnd = new Date(new Date(e.utcEnd).getTime() + delta).toISOString();
}
}
}
return merged;
}),
}));
} catch (error) {
debug.error('Failed to update event:', error);