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");
|
||||
|
||||
if (this.state.autoSave && this.state.fileHandle && supported) {
|
||||
try {
|
||||
this.saveLocalSceneDebounced(
|
||||
this.scene.getElementsIncludingDeleted(),
|
||||
this.state,
|
||||
);
|
||||
} catch (error) {
|
||||
this.setState({ autoSave: false });
|
||||
}
|
||||
this.saveLocalSceneDebounced(
|
||||
this.scene.getElementsIncludingDeleted(),
|
||||
this.state,
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
@ -1054,8 +1050,19 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
||||
}, SCROLL_TIMEOUT);
|
||||
|
||||
private saveLocalSceneDebounced = debounce(
|
||||
(elements: readonly ExcalidrawElement[], state: AppState) => {
|
||||
saveAsJSON(elements, state);
|
||||
async (elements: readonly ExcalidrawElement[], state: AppState) => {
|
||||
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,
|
||||
);
|
||||
|
@ -248,6 +248,7 @@
|
||||
"width": "Width"
|
||||
},
|
||||
"toast": {
|
||||
"autosaveFailed": "Autosave failed.",
|
||||
"copyStyles": "Copied styles.",
|
||||
"copyToClipboard": "Copied to clipboard.",
|
||||
"copyToClipboardAsPng": "Copied {{exportSelection}} to clipboard as PNG\n({{exportColorScheme}})",
|
||||
|
Loading…
x
Reference in New Issue
Block a user