From 4f3c8895f363b1b7748bdd7279ef082d448ebe6a Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 22 Jan 2020 13:16:22 +0200 Subject: [PATCH] Import: hopefully fix infinite loading on import. --- src/Journals/ImportDialog.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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; } };