diff --git a/src/Journals/ImportDialog.tsx b/src/Journals/ImportDialog.tsx index de2104a..3b90730 100644 --- a/src/Journals/ImportDialog.tsx +++ b/src/Journals/ImportDialog.tsx @@ -116,7 +116,7 @@ class ImportDialog extends React.Component { console.error(e); alert('file reading has failed'); }; - reader.onload = () => { + reader.onload = async () => { try { const fileText = reader.result as string; const items = itemsCreator(fileText); @@ -136,22 +136,18 @@ class ImportDialog extends React.Component { return ret; }); - store.dispatch( + await store.dispatch( addEntries(this.props.etesync, syncJournal.journal.uid, journalItems, lastUid) - ).then(() => { - if (this.props.onClose) { - this.setState({ loading: false }); - this.props.onClose(); - } - }); + ); } catch (e) { console.error(e); alert('An error has occurred, please contact developers.'); + throw e; + } finally { if (this.props.onClose) { this.setState({ loading: false }); this.props.onClose(); } - throw e; } };