Fix the journal action to be change when changing event.

master
Tom Hacohen 7 years ago
parent 7e271b1542
commit 9521e3dae3

@ -30,7 +30,7 @@ class EventEdit extends React.Component {
collections: Array<EteSync.CollectionInfo>, collections: Array<EteSync.CollectionInfo>,
initialCollection?: string, initialCollection?: string,
event?: EventType, event?: EventType,
onSave: (event: EventType, journalUid: string) => void; onSave: (event: EventType, journalUid: string, originalEvent?: EventType) => void;
}; };
constructor(props: any) { constructor(props: any) {
@ -108,7 +108,7 @@ class EventEdit extends React.Component {
event.location = this.state.location; event.location = this.state.location;
event.description = this.state.description; event.description = this.state.description;
this.props.onSave(event, this.state.journalUid); this.props.onSave(event, this.state.journalUid, this.props.event);
} }
render() { render() {

@ -40,7 +40,7 @@ class Pim extends React.Component {
this.onEventSave = this.onEventSave.bind(this); this.onEventSave = this.onEventSave.bind(this);
} }
onEventSave(event: EventType, journalUid: string) { onEventSave(event: EventType, journalUid: string, originalEvent?: EventType) {
const journal = this.props.journals.find((x) => (x.uid === journalUid)); const journal = this.props.journals.find((x) => (x.uid === journalUid));
if (journal === undefined) { if (journal === undefined) {
@ -53,7 +53,9 @@ class Pim extends React.Component {
return; return;
} }
let saveEvent = store.dispatch(createJournalEntry(this.props.etesync, journal, entries.value, event.toIcal())); let action = (originalEvent === undefined) ? EteSync.SyncEntryAction.Add : EteSync.SyncEntryAction.Change;
let saveEvent = store.dispatch(
createJournalEntry(this.props.etesync, journal, entries.value, action, event.toIcal()));
(saveEvent as any).then(() => { (saveEvent as any).then(() => {
this.props.history.goBack(); this.props.history.goBack();
}); });

@ -6,10 +6,11 @@ export function createJournalEntry(
etesync: CredentialsData, etesync: CredentialsData,
journal: EteSync.Journal, journal: EteSync.Journal,
existingEntries: Array<EteSync.Entry>, existingEntries: Array<EteSync.Entry>,
action: EteSync.SyncEntryAction,
content: string) { content: string) {
let syncEntry = new EteSync.SyncEntry(); let syncEntry = new EteSync.SyncEntry();
syncEntry.action = EteSync.SyncEntryAction.Add; syncEntry.action = action;
syncEntry.content = content; syncEntry.content = content;

Loading…
Cancel
Save