feat(calendar): Set the summary using prefix and override logic
This commit is contained in:
parent
d6022eeb62
commit
5ec6341680
|
@ -37,11 +37,12 @@ export function createCalendarComponent(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add events to the calendar component
|
// Add events to the calendar component
|
||||||
export function addEventsToCalendar(newCalendar, calendars, overrideFlag = false) {
|
export function addEventsToCalendar(newCalendar, calendars) {
|
||||||
let defaultTimeZone = null; // To store the first found X-WR-TIMEZONE
|
let defaultTimeZone = null; // To store the first found X-WR-TIMEZONE
|
||||||
|
|
||||||
calendars.forEach((calendarRaw) => {
|
calendars.forEach((calendarRaw) => {
|
||||||
try {
|
try {
|
||||||
|
const { data, prefix, override } = calendarRaw; // Extract prefix and override
|
||||||
const calendar = new ICAL.Component(ICAL.parse(calendarRaw.data));
|
const calendar = new ICAL.Component(ICAL.parse(calendarRaw.data));
|
||||||
|
|
||||||
// Extract METHOD from the parsed data (if available)
|
// Extract METHOD from the parsed data (if available)
|
||||||
|
@ -87,10 +88,10 @@ export function addEventsToCalendar(newCalendar, calendars, overrideFlag = false
|
||||||
const dtstamp = vevent.getFirstPropertyValue('dtstamp');
|
const dtstamp = vevent.getFirstPropertyValue('dtstamp');
|
||||||
if (dtstamp) newEvent.component.updatePropertyWithValue('dtstamp', dtstamp);
|
if (dtstamp) newEvent.component.updatePropertyWithValue('dtstamp', dtstamp);
|
||||||
|
|
||||||
if (overrideFlag) {
|
if (override) {
|
||||||
newEvent.summary = 'Busy'
|
newEvent.summary = prefix || 'Busy';
|
||||||
} else {
|
} else {
|
||||||
newEvent.summary = event.summary;
|
newEvent.summary = prefix ? `${prefix} ${event.summary}` : event.summary;
|
||||||
if (event.location) newEvent.location = event.location;
|
if (event.location) newEvent.location = event.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue