1
0
Fork 0

feat(location): conditionally handle VEVENT location based on override flag

This commit is contained in:
Ryan Mwangi 2024-11-19 13:21:22 +03:00
parent 2b7002303c
commit d2b0234b4b
1 changed files with 11 additions and 4 deletions

View File

@ -35,7 +35,7 @@ export function createCalendarComponent(name) {
} }
// Add events to the calendar component // Add events to the calendar component
export function addEventsToCalendar(calendarComponent, results) { export function addEventsToCalendar(calendarComponent, results, overrideFlag = false) {
results.forEach((result) => { results.forEach((result) => {
try { try {
const parsed = ICAL.parse(result.data); const parsed = ICAL.parse(result.data);
@ -84,9 +84,16 @@ export function addEventsToCalendar(calendarComponent, results) {
newEvent.addProperty(dtstartProp); newEvent.addProperty(dtstartProp);
} }
// 4. location // Add LOCATION (conditionally included)
const location = vevent.location; if (!overrideFlag && vevent.location) {
if (location) newEvent.updatePropertyWithValue('location', 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 // 5. Copy Recurrence Rules (RRULE) and Recurrence ID
const rrule = event.getFirstPropertyValue('rrule'); const rrule = event.getFirstPropertyValue('rrule');