diff --git a/src/Pim/PimMain.tsx b/src/Pim/PimMain.tsx index 26d5195..e5cdf91 100644 --- a/src/Pim/PimMain.tsx +++ b/src/Pim/PimMain.tsx @@ -40,7 +40,7 @@ interface PropsType { history?: History; theme: Theme; collectionsTaskList: EteSync.CollectionInfo[]; - onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => void; + onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => Promise; } class PimMain extends React.PureComponent { diff --git a/src/Pim/index.tsx b/src/Pim/index.tsx index a0ad476..b38d502 100644 --- a/src/Pim/index.tsx +++ b/src/Pim/index.tsx @@ -110,7 +110,7 @@ type CollectionRoutesPropsType = RouteComponentProps<{}> & { componentEdit: any; componentView: any; items: {[key: string]: PimType}; - onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => void; + onItemSave: (item: PimType, journalUid: string, originalItem?: PimType) => Promise; onItemDelete: (item: PimType, journalUid: string) => void; onItemCancel: () => void; classes: any; @@ -144,6 +144,7 @@ const CollectionRoutes = withStyles(styles)(withRouter( collections={props.collections} onSave={props.onItemSave} onCancel={props.onItemCancel} + history={props.history} /> )} @@ -161,6 +162,7 @@ const CollectionRoutes = withStyles(styles)(withRouter( onSave={props.onItemSave} onDelete={props.onItemDelete} onCancel={props.onItemCancel} + history={props.history} /> } @@ -238,11 +240,11 @@ class Pim extends React.PureComponent { this.onItemSave = this.onItemSave.bind(this); } - public onItemSave(item: PimType, journalUid: string, originalEvent?: PimType) { + public onItemSave(item: PimType, journalUid: string, originalEvent?: PimType): Promise { const syncJournal = this.props.syncInfo.get(journalUid); if (syncJournal === undefined) { - return; + return Promise.reject(); } const journal = syncJournal.journal; @@ -254,7 +256,7 @@ class Pim extends React.PureComponent { if (last) { prevUid = last.uid; } - store.dispatch(fetchEntries(this.props.etesync, journal.uid, prevUid)) + return store.dispatch(fetchEntries(this.props.etesync, journal.uid, prevUid)) .then((entriesAction: Action) => { last = entriesAction.payload!.slice(-1).pop() as EteSync.Entry; @@ -263,13 +265,10 @@ class Pim extends React.PureComponent { prevUid = last.uid; } - const saveEvent = store.dispatch( + return store.dispatch( addJournalEntry( this.props.etesync, this.props.userInfo, journal, prevUid, action, item.toIcal())); - (saveEvent as any).then(() => { - this.props.history.goBack(); - }); }); } diff --git a/src/components/ContactEdit.tsx b/src/components/ContactEdit.tsx index d2fb3de..1b32b21 100644 --- a/src/components/ContactEdit.tsx +++ b/src/components/ContactEdit.tsx @@ -26,6 +26,8 @@ import * as EteSync from 'etesync'; import { ContactType } from '../pim-types'; +import { History } from 'history'; + const telTypes = [ { type: 'Home' }, { type: 'Work' }, @@ -48,7 +50,7 @@ const imppTypes = [ ]; const TypeSelector = (props: any) => { - const types = props.types as Array<{type: string}>; + const types = props.types as Array<{ type: string }>; return (