From 3794d6c05a4d11358f75467ef01666643fdf3e60 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 8 Dec 2017 20:47:52 +0000 Subject: [PATCH] Implement last modified for contacts. --- src/Contact.tsx | 12 ++++++++++-- src/ical.js.d.ts | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Contact.tsx b/src/Contact.tsx index d4d3966..6b99c07 100644 --- a/src/Contact.tsx +++ b/src/Contact.tsx @@ -27,6 +27,10 @@ class Contact extends React.Component { const contact = this.props.contact; const name = contact.fn; + const revProp = contact.comp.getFirstProperty('rev'); + const lastModified = (revProp !== undefined) ? + 'Modified: ' + moment(revProp.getFirstValue().toJSDate()).format('LLLL') : undefined; + let lists = []; function getAllType( @@ -105,7 +109,7 @@ class Contact extends React.Component { () => 'Anniversary', )); - const skips = ['tel', 'email', 'impp', 'adr', 'bday', 'anniversary', + const skips = ['tel', 'email', 'impp', 'adr', 'bday', 'anniversary', 'rev', 'prodid', 'uid', 'fn', 'n', 'version', 'photo']; const theRest = contact.comp.getAllProperties().filter((prop) => ( skips.indexOf(prop.name) === -1 @@ -141,7 +145,11 @@ class Contact extends React.Component { return (
- + + {lastModified && ( + {lastModified} + )} + {lists.map((list, idx) => ( {listIfNotEmpty(list)} diff --git a/src/ical.js.d.ts b/src/ical.js.d.ts index 246de17..3b2e4f6 100644 --- a/src/ical.js.d.ts +++ b/src/ical.js.d.ts @@ -7,8 +7,9 @@ declare module 'ical.js' { getFirstSubcomponent(name?: string): Component | null; - getFirstPropertyValue(name?: string): string; + getFirstPropertyValue(name?: string): any; + getFirstProperty(name?: string): Property; getAllProperties(name?: string): Array; } @@ -29,7 +30,7 @@ declare module 'ical.js' { name: string; type: string; - getFirstValue(): string; + getFirstValue(): any; getValues(): Array; toJSON(): any; }