Fixed error message not being displayed on load failure.

This commit is contained in:
Przemek Wiech
2019-01-31 23:55:31 +01:00
parent 71e2d0fae1
commit 3b4f05e9fc

View File

@@ -130,9 +130,9 @@ export class ChartView extends React.Component<RouteComponentProps, State> {
indi?: string; indi?: string;
generation?: number; generation?: number;
}) { }) {
const hash = md5(input.gedcom);
try { try {
const data = convertGedcom(input.gedcom); const data = convertGedcom(input.gedcom);
const hash = md5(input.gedcom);
const serializedData = JSON.stringify(data); const serializedData = JSON.stringify(data);
sessionStorage.setItem(input.url || hash, serializedData); sessionStorage.setItem(input.url || hash, serializedData);
this.setState( this.setState(
@@ -142,10 +142,20 @@ export class ChartView extends React.Component<RouteComponentProps, State> {
hash, hash,
loading: false, loading: false,
loadedUrl: input.url, loadedUrl: input.url,
error: undefined,
}), }),
); );
} catch (e) { } catch (e) {
this.setState(Object.assign({}, this.state, {error: e.message})); this.setState(
Object.assign({}, this.state, {
data: undefined,
selection: undefined,
hash,
loading: false,
error: 'Failed to read GEDCOM file',
loadedUrl: input.url,
}),
);
} }
} }