405 back reload token with synctokens (#436)

* [#405] added syncToken in calendar params and fetch with sync token

* [#405] changed reload to work with sync-token

* [#405] fixup promise handling, added calendar adding and removing hanlding with refresh

* [#405]  fixed event expansion calls

* [#405 & refactor] added helperfunction to get base event uid + refactored synctoken updates management

* [#405] added pMap lib to process event expansion

* [#405] added flag for no synctoken / new synctoken
This commit is contained in:
Camille Moussu
2026-01-13 11:06:34 +01:00
committed by GitHub
parent bcc3019e4b
commit 478a0e0eb0
36 changed files with 1323 additions and 281 deletions
+19 -2
View File
@@ -10,7 +10,8 @@ import {
import ICAL from "ical.js";
import moment from "moment-timezone";
import { detectDateTimeFormat } from "../../components/Event/utils/dateTimeHelpers";
import { User } from "../../components/Attendees/PeopleSearch";
import { CalDavItem } from "../Calendars/api/types";
import { extractEventBaseUuid } from "../../utils/extractEventBaseUuid";
function resolveTimezoneId(tzid?: string): string | undefined {
if (!tzid) return undefined;
@@ -23,6 +24,22 @@ function resolveTimezoneId(tzid?: string): string | undefined {
return tzid;
}
export async function reportEvent(
event: CalendarEvent,
match: { start: string; end: string }
): Promise<CalDavItem> {
const response = await api(`dav${event.URL}`, {
method: "REPORT",
body: JSON.stringify({ match }),
headers: { Accept: "application/json" },
});
if (!response.ok) {
throw new Error(`REPORT request failed with status ${response.status}`);
}
const eventData: CalDavItem = await response.json();
return eventData;
}
export async function getEvent(event: CalendarEvent, isMaster?: boolean) {
const response = await api.get(`dav${event.URL}`);
const eventData = await response.text();
@@ -227,7 +244,7 @@ export const deleteEventInstance = async (
const seriesEvent = await getEvent(
{
...event,
uid: event.uid.split("/")[0],
uid: extractEventBaseUuid(event.uid),
},
true
);
+7 -6
View File
@@ -42,6 +42,7 @@ import {
EventFormContext,
} from "../../utils/eventFormTempStorage";
import { browserDefaultTimeZone } from "../../utils/timezone";
import { extractEventBaseUuid } from "../../utils/extractEventBaseUuid";
function EventUpdateModal({
eventId,
@@ -261,7 +262,7 @@ function EventUpdateModal({
setCalendarid(calId);
// Handle repetition properly - check both current event and base event
const baseEventId = event.uid.split("/")[0];
const baseEventId = extractEventBaseUuid(event.uid);
const baseEvent = calendarsList[calId]?.events[baseEventId];
const repetitionSource = event.repetition || baseEvent?.repetition;
@@ -478,7 +479,7 @@ function EventUpdateModal({
Object.keys(seriesEvents).forEach((eventId) => {
const instance = seriesEvents[eventId];
if (instance && eventId.split("/")[0] === baseUID) {
if (instance && extractEventBaseUuid(eventId) === baseUID) {
instances[eventId] = { ...instance };
}
});
@@ -614,7 +615,7 @@ function EventUpdateModal({
event.repetition?.freq &&
!repetition.freq
) {
const baseUID = event.uid.split("/")[0];
const baseUID = extractEventBaseUuid(event.uid);
// Save current form data to temp storage before closing
const formDataToSave = saveCurrentFormData();
@@ -653,7 +654,7 @@ function EventUpdateModal({
// Collect all instances that need to be deleted
const instancesToDelete = Object.keys(targetCalendar.events)
.filter((eventId) => eventId.split("/")[0] === baseUID)
.filter((eventId) => extractEventBaseUuid(eventId) === baseUID)
.map((eventId) => targetCalendar.events[eventId]);
// Get unique URLs to avoid deleting same file multiple times
@@ -819,7 +820,7 @@ function EventUpdateModal({
}
} else if (typeOfAction === "all") {
// Update all instances - check if repetition rules changed
const baseUID = event.uid.split("/")[0];
const baseUID = extractEventBaseUuid(event.uid);
const changes = detectRecurringEventChanges(
event,
@@ -1074,7 +1075,7 @@ function EventUpdateModal({
moveEventAsync({
cal: targetCalendar,
newEvent,
newURL: `/calendars/${newCalId}/${event.uid.split("/")[0]}.ics`,
newURL: `/calendars/${newCalId}/${extractEventBaseUuid(event.uid)}.ics`,
})
);
+3 -2
View File
@@ -8,6 +8,7 @@ import {
detectDateTimeFormat,
} from "../../components/Event/utils/dateTimeHelpers";
import { createAttendee } from "../User/models/attendee.mapper";
import { extractEventBaseUuid } from "../../utils/extractEventBaseUuid";
type RawEntry = [string, Record<string, string>, string, any];
function resolveTimezoneId(tzid?: string): string | undefined {
@@ -189,7 +190,7 @@ export function parseCalendarEvent(
}
}
}
event.calId = calendarid;
event.URL = eventURL;
if (!event.uid || !event.start) {
console.error(
@@ -293,7 +294,7 @@ export function makeVevent(
const vevent: any[] = [
"vevent",
[
["uid", {}, "text", event.uid.split("/")[0]],
["uid", {}, "text", extractEventBaseUuid(event.uid)],
["transp", {}, "text", event.transp ?? "OPAQUE"],
[
"dtstart",
+2 -1
View File
@@ -5,6 +5,7 @@ import { userAttendee } from "../User/models/attendee";
import { formatDateTimeInTimezone } from "../../components/Event/utils/dateTimeFormatters";
import { addVideoConferenceToDescription } from "../../utils/videoConferenceUtils";
import { browserDefaultTimeZone } from "../../utils/timezone";
import { extractEventBaseUuid } from "../../utils/extractEventBaseUuid";
export interface TimezoneListResult {
zones: string[];
@@ -133,7 +134,7 @@ export function populateFormFromEvent(
// Handle repetition - check both current event and base event (for update modal)
let repetitionSource = event.repetition;
if (calendarsList && calId && event.uid) {
const baseEventId = event.uid.split("/")[0];
const baseEventId = extractEventBaseUuid(event.uid);
const baseEvent = calendarsList[calId]?.events[baseEventId];
if (baseEvent?.repetition) {
repetitionSource = baseEvent.repetition;