handle error properly and display error message
This commit is contained in:
parent
01f5914a82
commit
f68404fbed
@ -911,14 +911,10 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||||||
?.classList.toggle("theme--dark", this.state.theme === "dark");
|
?.classList.toggle("theme--dark", this.state.theme === "dark");
|
||||||
|
|
||||||
if (this.state.autoSave && this.state.fileHandle && supported) {
|
if (this.state.autoSave && this.state.fileHandle && supported) {
|
||||||
try {
|
this.saveLocalSceneDebounced(
|
||||||
this.saveLocalSceneDebounced(
|
this.scene.getElementsIncludingDeleted(),
|
||||||
this.scene.getElementsIncludingDeleted(),
|
this.state,
|
||||||
this.state,
|
);
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
this.setState({ autoSave: false });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -1054,8 +1050,19 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||||||
}, SCROLL_TIMEOUT);
|
}, SCROLL_TIMEOUT);
|
||||||
|
|
||||||
private saveLocalSceneDebounced = debounce(
|
private saveLocalSceneDebounced = debounce(
|
||||||
(elements: readonly ExcalidrawElement[], state: AppState) => {
|
async (elements: readonly ExcalidrawElement[], state: AppState) => {
|
||||||
saveAsJSON(elements, state);
|
if (this.state.autoSave && this.state.fileHandle && supported) {
|
||||||
|
try {
|
||||||
|
await saveAsJSON(elements, state);
|
||||||
|
} catch (error) {
|
||||||
|
// shouldn't (almost) ever happen, so let's log it
|
||||||
|
console.error(error);
|
||||||
|
this.setState({
|
||||||
|
autoSave: false,
|
||||||
|
errorMessage: t("toast.autosaveFailed"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
AUTO_SAVE_TIMEOUT,
|
AUTO_SAVE_TIMEOUT,
|
||||||
);
|
);
|
||||||
|
@ -248,6 +248,7 @@
|
|||||||
"width": "Width"
|
"width": "Width"
|
||||||
},
|
},
|
||||||
"toast": {
|
"toast": {
|
||||||
|
"autosaveFailed": "Autosave failed.",
|
||||||
"copyStyles": "Copied styles.",
|
"copyStyles": "Copied styles.",
|
||||||
"copyToClipboard": "Copied to clipboard.",
|
"copyToClipboard": "Copied to clipboard.",
|
||||||
"copyToClipboardAsPng": "Copied {{exportSelection}} to clipboard as PNG\n({{exportColorScheme}})",
|
"copyToClipboardAsPng": "Copied {{exportSelection}} to clipboard as PNG\n({{exportColorScheme}})",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user