Implement a common interface for pim types.

master
Tom Hacohen 7 years ago
parent bfa186dc35
commit 074fc8e6c0

@ -13,7 +13,7 @@ import { pure } from 'recompose';
import { History } from 'history'; import { History } from 'history';
import { ContactType, EventType } from '../pim-types'; import { PimType, ContactType, EventType } from '../pim-types';
import Container from '../widgets/Container'; import Container from '../widgets/Container';
@ -72,7 +72,7 @@ const ItemChangeLog = pure((props: any) => {
uid, uid,
} = props; } = props;
const journalItem = syncInfo.get((items[uid] as any).journalUid); const journalItem = syncInfo.get(items[uid].journalUid);
return ( return (
<React.Fragment> <React.Fragment>
@ -94,9 +94,9 @@ const CollectionRoutes = withRouter(
collections: Array<EteSync.CollectionInfo>, collections: Array<EteSync.CollectionInfo>,
componentEdit: any, componentEdit: any,
componentView: any, componentView: any,
items: {[key: string]: any}, items: {[key: string]: PimType},
onItemSave: (item: Object, journalUid: string, originalContact?: Object) => void; onItemSave: (item: PimType, journalUid: string, originalContact?: PimType) => void;
onItemDelete: (item: Object, journalUid: string) => void; onItemDelete: (item: PimType, journalUid: string) => void;
onItemCancel: () => void; onItemCancel: () => void;
}; };
@ -204,7 +204,7 @@ class Pim extends React.PureComponent {
this.onItemSave = this.onItemSave.bind(this); this.onItemSave = this.onItemSave.bind(this);
} }
onItemSave(item: any, journalUid: string, originalEvent?: any) { onItemSave(item: PimType, journalUid: string, originalEvent?: PimType) {
const syncJournal = this.props.syncInfo.get(journalUid); const syncJournal = this.props.syncInfo.get(journalUid);
if (syncJournal === undefined) { if (syncJournal === undefined) {
@ -221,7 +221,7 @@ class Pim extends React.PureComponent {
}); });
} }
onItemDelete(item: any, journalUid: string) { onItemDelete(item: PimType, journalUid: string) {
const syncJournal = this.props.syncInfo.get(journalUid); const syncJournal = this.props.syncInfo.get(journalUid);
if (syncJournal === undefined) { if (syncJournal === undefined) {

@ -1,6 +1,12 @@
import * as ICAL from 'ical.js'; import * as ICAL from 'ical.js';
export class EventType extends ICAL.Event { export interface PimType {
uid: string;
toIcal(): string;
clone(): PimType;
}
export class EventType extends ICAL.Event implements PimType {
color: string; color: string;
static fromVCalendar(comp: ICAL.Component) { static fromVCalendar(comp: ICAL.Component) {
@ -33,7 +39,7 @@ export class EventType extends ICAL.Event {
} }
} }
export class ContactType { export class ContactType implements PimType {
comp: ICAL.Component; comp: ICAL.Component;
constructor(comp: ICAL.Component) { constructor(comp: ICAL.Component) {

Loading…
Cancel
Save