Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -334,12 +334,13 @@ const CalendarSlice = createSlice({
|
||||
|
||||
if (syncStatus === "SUCCESS") {
|
||||
const deletedSet = new Set(deletedEvents); // working with a Set for deletion avoids O(nxm) complexity
|
||||
Object.keys(target.events)
|
||||
.filter((eventKey) => {
|
||||
const baseUid = extractEventBaseUuid(eventKey);
|
||||
return deletedSet.has(eventKey) || deletedSet.has(baseUid);
|
||||
Object.values(target.events)
|
||||
.filter((event) => {
|
||||
return deletedSet.has(event.URL);
|
||||
})
|
||||
.forEach((eventKey) => delete target.events[eventKey]);
|
||||
.forEach((event) => {
|
||||
delete target.events[event.uid];
|
||||
});
|
||||
|
||||
for (const event of createdOrUpdatedEvents) {
|
||||
target.events[event.uid] = event;
|
||||
|
||||
@@ -14,13 +14,11 @@ export function processSyncUpdates(
|
||||
for (const update of updates) {
|
||||
const href = update?._links?.self?.href;
|
||||
if (!href) continue;
|
||||
const fileName = extractFileNameFromHref(href);
|
||||
|
||||
if (update.status === 404) {
|
||||
toDelete.push(fileName);
|
||||
toDelete.push(href);
|
||||
} else if (update.status === 200) {
|
||||
toExpand.push(href);
|
||||
toDelete.push(fileName); // we delete the old version of the event to replace it by the new when it's updated
|
||||
toDelete.push(href); // we delete the old version of the event to replace it by the new when it's updated
|
||||
} else if (update.status === 410) {
|
||||
throw new Error("SYNC_TOKEN_INVALID");
|
||||
}
|
||||
@@ -28,8 +26,3 @@ export function processSyncUpdates(
|
||||
|
||||
return { toDelete, toExpand };
|
||||
}
|
||||
|
||||
function extractFileNameFromHref(href: string): string {
|
||||
const fileNameMatch = href.match(/\/([^/]+)\.ics$/); // CalDAV href are like /calendars/userID/CalendarID/EventId.ics
|
||||
return fileNameMatch ? fileNameMatch[1] : href;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ export default function EventPreviewModal({
|
||||
setOpenDuplicateModal(true);
|
||||
}}
|
||||
/>
|
||||
{isOrganizer && (
|
||||
{isOwn && (
|
||||
<MenuItem
|
||||
onClick={async () => {
|
||||
if (isRecurring) {
|
||||
|
||||
Reference in New Issue
Block a user