From 0fb37c1132f9fd1134150d2b3401d9f6ce63b09a Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 11 Dec 2017 18:27:33 +0000 Subject: [PATCH] Move the creating event from calendar to one place. --- src/JournalEntries.tsx | 2 +- src/journal-processors.tsx | 2 +- src/pim-types.tsx | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) 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 {