[#465] changed render to show delete option when event is Own (#543)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2026-02-17 09:47:57 +01:00
committed by GitHub
parent f8e159a618
commit c7843f8d69
4 changed files with 12 additions and 18 deletions
@@ -110,7 +110,7 @@ describe("refreshCalendarWithSyncToken", () => {
expect(result.type).toBe("calendars/refreshWithSyncToken/fulfilled");
expect(result.payload).toMatchObject({
calId: mockCalendar.id,
deletedEvents: ["deleted-event"],
deletedEvents: ["/calendars/user1/cal1/deleted-event.ics"],
createdOrUpdatedEvents: [],
syncToken: "new-sync-token-456",
});
@@ -236,8 +236,8 @@ describe("refreshCalendarWithSyncToken", () => {
if (result.type === "calendars/refreshWithSyncToken/fulfilled") {
const payload = result.payload as SyncTokenUpdates;
expect(payload?.deletedEvents).toEqual([
"deleted-event",
"updated-event",
"/calendars/user1/cal1/deleted-event.ics",
"/calendars/user1/cal1/updated-event.ics",
]);
expect(payload?.createdOrUpdatedEvents).toHaveLength(1);
expect(payload?.createdOrUpdatedEvents[0].uid).toBe("updated-event");
+6 -5
View File
@@ -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;
}
+1 -1
View File
@@ -380,7 +380,7 @@ export default function EventPreviewModal({
setOpenDuplicateModal(true);
}}
/>
{isOrganizer && (
{isOwn && (
<MenuItem
onClick={async () => {
if (isRecurring) {