Import: hopefully fix infinite loading on import.

master
Tom Hacohen 5 years ago
parent d0ec686592
commit 4f3c8895f3

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

Loading…
Cancel
Save