fix: handle converting recurring events to non-recurring events in edit all mode
This commit is contained in:
committed by
Benoit TELLIER
parent
474ff22cab
commit
2ba80fcdb6
@@ -46,7 +46,7 @@ import {
|
|||||||
import { Calendars } from "../Calendars/CalendarTypes";
|
import { Calendars } from "../Calendars/CalendarTypes";
|
||||||
import { userAttendee } from "../User/userDataTypes";
|
import { userAttendee } from "../User/userDataTypes";
|
||||||
import { getEvent } from "./EventApi";
|
import { getEvent } from "./EventApi";
|
||||||
import { formatLocalDateTime } from "../../components/Event/EventFormFields";
|
import { formatLocalDateTime } from "./EventModal";
|
||||||
import { CalendarEvent, RepetitionObject } from "./EventsTypes";
|
import { CalendarEvent, RepetitionObject } from "./EventsTypes";
|
||||||
|
|
||||||
export default function EventDisplayModal({
|
export default function EventDisplayModal({
|
||||||
|
|||||||
@@ -361,12 +361,38 @@ function EventUpdateModal({
|
|||||||
);
|
);
|
||||||
} else if (typeOfAction === "all") {
|
} else if (typeOfAction === "all") {
|
||||||
// Update all instances
|
// Update all instances
|
||||||
dispatch(
|
|
||||||
updateSeriesAsync({
|
// Special case: When converting recurring event to non-recurring
|
||||||
cal: targetCalendar,
|
if (event.repetition?.freq && !repetition.freq) {
|
||||||
event: { ...newEvent, recurrenceId },
|
// For repeat -> no-repeat, create a new non-repeating event
|
||||||
})
|
dispatch(
|
||||||
);
|
putEventAsync({
|
||||||
|
cal: targetCalendar,
|
||||||
|
newEvent: {
|
||||||
|
...newEvent,
|
||||||
|
uid: crypto.randomUUID(), // Generate new ID for the single event
|
||||||
|
URL: `/calendars/${newCalId || calId}/${crypto.randomUUID()}.ics`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete the old repeating series
|
||||||
|
const baseUID = event.uid.split("/")[0];
|
||||||
|
Object.keys(targetCalendar.events).forEach((eventId) => {
|
||||||
|
if (eventId.split("/")[0] === baseUID) {
|
||||||
|
dispatch(removeEvent({ calendarUid: calId, eventUid: eventId }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Normal update for recurring events
|
||||||
|
dispatch(
|
||||||
|
updateSeriesAsync({
|
||||||
|
cal: targetCalendar,
|
||||||
|
event: { ...newEvent, recurrenceId },
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh calendars to ensure all instances are updated
|
// Refresh calendars to ensure all instances are updated
|
||||||
const calendarRange = getCalendarRange(new Date(start));
|
const calendarRange = getCalendarRange(new Date(start));
|
||||||
await refreshCalendars(dispatch, Object.values(calendarsList), calendarRange);
|
await refreshCalendars(dispatch, Object.values(calendarsList), calendarRange);
|
||||||
|
|||||||
Reference in New Issue
Block a user