diff --git a/src/actions/actionExport.tsx b/src/actions/actionExport.tsx index bfe57d64..54d832f8 100644 --- a/src/actions/actionExport.tsx +++ b/src/actions/actionExport.tsx @@ -92,7 +92,7 @@ export const actionLoadScene = register({ updateData({ elements: elements, appState: appState }); }) .catch((error) => { - updateData({ error: error }); + updateData({ error: error.message }); }); }} /> diff --git a/src/components/App.tsx b/src/components/App.tsx index d95da0e1..4c3be550 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2358,7 +2358,7 @@ export class App extends React.Component { }), ) .catch((error) => { - this.setState({ isLoading: false, errorMessage: error }); + this.setState({ isLoading: false, errorMessage: error.message }); }); } else { this.setState({ diff --git a/src/data/blob.ts b/src/data/blob.ts index 53204de1..7d36208a 100644 --- a/src/data/blob.ts +++ b/src/data/blob.ts @@ -1,5 +1,4 @@ import { getDefaultAppState } from "../appState"; -import { DataState } from "./types"; import { restore } from "./restore"; import { t } from "../i18n"; @@ -16,7 +15,7 @@ export async function loadFromBlob(blob: any) { elements = data.elements || []; appState = { ...defaultAppState, ...data.appState }; } catch { - // Do nothing because elements array is already empty + throw new Error(t("alerts.couldNotLoadInvalidFile")); } return { elements, appState }; }; @@ -38,11 +37,7 @@ export async function loadFromBlob(blob: any) { }; }); } + const { elements, appState } = updateAppState(contents); - if (!elements.length) { - return Promise.reject(t("alerts.couldNotLoadInvalidFile")); - } - return new Promise((resolve) => { - resolve(restore(elements, appState, { scrollToContent: true })); - }); + return restore(elements, appState, { scrollToContent: true }); }