From d2b0234b4b31edb53de7590275bfda1f6f5ed526 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Tue, 19 Nov 2024 13:21:22 +0300 Subject: [PATCH] feat(location): conditionally handle VEVENT location based on override flag --- src/calendarUtil.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/calendarUtil.js b/src/calendarUtil.js index b684917..8137161 100644 --- a/src/calendarUtil.js +++ b/src/calendarUtil.js @@ -35,7 +35,7 @@ export function createCalendarComponent(name) { } // Add events to the calendar component -export function addEventsToCalendar(calendarComponent, results) { +export function addEventsToCalendar(calendarComponent, results, overrideFlag = false) { results.forEach((result) => { try { const parsed = ICAL.parse(result.data); @@ -84,9 +84,16 @@ export function addEventsToCalendar(calendarComponent, results) { newEvent.addProperty(dtstartProp); } - // 4. location - const location = vevent.location; - if (location) newEvent.updatePropertyWithValue('location', location); + // Add LOCATION (conditionally included) + if (!overrideFlag && vevent.location) { + newEvent.updatePropertyWithValue('location', vevent.location); + } else if (overrideFlag && vevent.location) { + // Modify SUMMARY if override is set + const modifiedSummary = `${vevent.summary.trim()} (Location omitted)`; + newEvent.updatePropertyWithValue('summary', modifiedSummary); + } else { + newEvent.updatePropertyWithValue('summary', vevent.summary.trim()); + } // 5. Copy Recurrence Rules (RRULE) and Recurrence ID const rrule = event.getFirstPropertyValue('rrule');