diff --git a/src/JournalEntries.tsx b/src/JournalEntries.tsx index 1303b32..f33c64b 100644 --- a/src/JournalEntries.tsx +++ b/src/JournalEntries.tsx @@ -51,7 +51,7 @@ class JournalEntries extends React.Component { let name; let uid; if (comp.name === 'vcalendar') { - const vevent = new EventType(comp.getFirstSubcomponent('vevent')); + const vevent = EventType.fromVCalendar(comp); name = vevent.summary; uid = vevent.uid; } else if (comp.name === 'vcard') { diff --git a/src/journal-processors.tsx b/src/journal-processors.tsx index 2e70093..1011f23 100644 --- a/src/journal-processors.tsx +++ b/src/journal-processors.tsx @@ -50,7 +50,7 @@ export function syncEntriesToCalendarItemMap(collection: EteSync.CollectionInfo, const color = colorIntToHtml(collection.color); for (const syncEntry of entries) { - let comp = new EventType(new ICAL.Component(ICAL.parse(syncEntry.content)).getFirstSubcomponent('vevent')); + let comp = EventType.fromVCalendar(new ICAL.Component(ICAL.parse(syncEntry.content))); if (comp === null) { continue; diff --git a/src/pim-types.tsx b/src/pim-types.tsx index db5b4bd..b263885 100644 --- a/src/pim-types.tsx +++ b/src/pim-types.tsx @@ -14,6 +14,10 @@ export class EventType extends ICAL.Event { get end() { return this.endDate.toJSDate(); } + + static fromVCalendar(comp: ICAL.Component) { + return new EventType(comp.getFirstSubcomponent('vevent')); + } } export class ContactType {