diff --git a/src/JournalViewAddressBook.tsx b/src/JournalViewAddressBook.tsx index cb8be9e..fd7612c 100644 --- a/src/JournalViewAddressBook.tsx +++ b/src/JournalViewAddressBook.tsx @@ -19,7 +19,7 @@ export class JournalViewAddressBook extends React.Component { return (
Loading
); } - let items: Map = new Map(); + let items: Map = new Map(); for (const syncEntry of this.props.entries) { let comp = new ICAL.Component(ICAL.parse(syncEntry.content)); @@ -34,8 +34,7 @@ export class JournalViewAddressBook extends React.Component { } } - // FIXME: should be ICAL.component - let entries: Array = Array.from(items.values()).sort((_a: any, _b: any) => { + let entries = Array.from(items.values()).sort((_a, _b) => { const a = _a.getFirstPropertyValue('fn'); const b = _b.getFirstPropertyValue('fn'); diff --git a/src/JournalViewCalendar.tsx b/src/JournalViewCalendar.tsx index f4bc790..5a97ff4 100644 --- a/src/JournalViewCalendar.tsx +++ b/src/JournalViewCalendar.tsx @@ -19,11 +19,15 @@ export class JournalViewCalendar extends React.Component { return (
Loading
); } - let items: Map = new Map(); + let items: Map = new Map(); for (const syncEntry of this.props.entries) { let comp = new ICAL.Component(ICAL.parse(syncEntry.content)).getFirstSubcomponent('vevent'); + if (comp === null) { + continue; + } + const uid = comp.getFirstPropertyValue('uid'); if ((syncEntry.action === EteSync.SyncEntryAction.Add) || @@ -34,10 +38,9 @@ export class JournalViewCalendar extends React.Component { } } - // FIXME: should be ICAL.component - let entries: Array = Array.from(items.values()).map((value: string) => ( + let entries = Array.from(items.values()).map((value) => ( new ICAL.Event(value) - )).sort((a: any, b: any) => { + )).sort((a, b) => { if (a.summary < b.summary) { return -1; } else if (a.summary > b.summary) { diff --git a/src/ical.js.d.ts b/src/ical.js.d.ts index ccd4a6c..fc05263 100644 --- a/src/ical.js.d.ts +++ b/src/ical.js.d.ts @@ -1,5 +1,20 @@ -declare var ICAL: any; - declare module 'ical.js' { - export = ICAL; + function parse(input: string): Array; + class Component { + name: string; + + constructor(jCal: Array | string, parent?: Component); + + getFirstSubcomponent(name?: string): Component | null; + + getFirstPropertyValue(name?: string): string; + } + + class Event { + uid: string; + summary: string; + + constructor(component?: Component | null, + options?: {strictExceptions: boolean, exepctions: Array}); + } }