Implement last modified for contacts.

master
Tom Hacohen 7 years ago
parent 6de0534bf9
commit 3794d6c05a

@ -27,6 +27,10 @@ class Contact extends React.Component {
const contact = this.props.contact; const contact = this.props.contact;
const name = contact.fn; const name = contact.fn;
const revProp = contact.comp.getFirstProperty('rev');
const lastModified = (revProp !== undefined) ?
'Modified: ' + moment(revProp.getFirstValue().toJSDate()).format('LLLL') : undefined;
let lists = []; let lists = [];
function getAllType( function getAllType(
@ -105,7 +109,7 @@ class Contact extends React.Component {
() => 'Anniversary', () => 'Anniversary',
)); ));
const skips = ['tel', 'email', 'impp', 'adr', 'bday', 'anniversary', const skips = ['tel', 'email', 'impp', 'adr', 'bday', 'anniversary', 'rev',
'prodid', 'uid', 'fn', 'n', 'version', 'photo']; 'prodid', 'uid', 'fn', 'n', 'version', 'photo'];
const theRest = contact.comp.getAllProperties().filter((prop) => ( const theRest = contact.comp.getAllProperties().filter((prop) => (
skips.indexOf(prop.name) === -1 skips.indexOf(prop.name) === -1
@ -141,7 +145,11 @@ class Contact extends React.Component {
return ( return (
<div> <div>
<PimItemHeader text={name} /> <PimItemHeader text={name}>
{lastModified && (
<span style={{fontSize: '90%'}}>{lastModified}</span>
)}
</PimItemHeader>
{lists.map((list, idx) => ( {lists.map((list, idx) => (
<React.Fragment key={idx}> <React.Fragment key={idx}>
{listIfNotEmpty(list)} {listIfNotEmpty(list)}

5
src/ical.js.d.ts vendored

@ -7,8 +7,9 @@ declare module 'ical.js' {
getFirstSubcomponent(name?: string): Component | null; getFirstSubcomponent(name?: string): Component | null;
getFirstPropertyValue(name?: string): string; getFirstPropertyValue(name?: string): any;
getFirstProperty(name?: string): Property;
getAllProperties(name?: string): Array<Property>; getAllProperties(name?: string): Array<Property>;
} }
@ -29,7 +30,7 @@ declare module 'ical.js' {
name: string; name: string;
type: string; type: string;
getFirstValue(): string; getFirstValue(): any;
getValues(): Array<any>; getValues(): Array<any>;
toJSON(): any; toJSON(): any;
} }

Loading…
Cancel
Save