From fcf2251e9bfef0a64bdcb477a937a49269cd266b Mon Sep 17 00:00:00 2001 From: 1ilit <1ilit@proton.me> Date: Sun, 1 Sep 2024 21:14:18 +0400 Subject: [PATCH] Handle incorrect links and corrupted files --- src/components/EditorHeader/ControlPanel.jsx | 4 +++- src/components/EditorHeader/Modal/Share.jsx | 5 +---- src/components/Workspace.jsx | 2 ++ src/data/constants.js | 1 + src/i18n/locales/en.js | 3 +++ 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/EditorHeader/ControlPanel.jsx b/src/components/EditorHeader/ControlPanel.jsx index dbd5c64..593e69d 100644 --- a/src/components/EditorHeader/ControlPanel.jsx +++ b/src/components/EditorHeader/ControlPanel.jsx @@ -1084,7 +1084,7 @@ export default function ControlPanel({ data: result, extension: "md", })); - } + }, }, ], function: () => {}, @@ -1604,6 +1604,8 @@ export default function ControlPanel({ return t("saving"); case State.ERROR: return t("failed_to_save"); + case State.FAILED_TO_LOAD: + return t("failed_to_load"); default: return ""; } diff --git a/src/components/EditorHeader/Modal/Share.jsx b/src/components/EditorHeader/Modal/Share.jsx index 420ff41..3731a3e 100644 --- a/src/components/EditorHeader/Modal/Share.jsx +++ b/src/components/EditorHeader/Modal/Share.jsx @@ -146,10 +146,7 @@ export default function Share({ title }) {
-
- * Sharing this link will not create a live real-time collaboration - session -
+
{t("share_info")}
); } diff --git a/src/components/Workspace.jsx b/src/components/Workspace.jsx index 77436f0..ce9a4f6 100644 --- a/src/components/Workspace.jsx +++ b/src/components/Workspace.jsx @@ -356,6 +356,7 @@ export default function WorkSpace() { } } catch (e) { console.log(e); + setSaveState(State.FAILED_TO_LOAD); } }, [ @@ -369,6 +370,7 @@ export default function WorkSpace() { setTransform, setRedoStack, setUndoStack, + setSaveState, ], ); diff --git a/src/data/constants.js b/src/data/constants.js index 59bd4ff..e17b7d1 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -77,6 +77,7 @@ export const State = { SAVED: 2, LOADING: 3, ERROR: 4, + FAILED_TO_LOAD: 5, }; export const MODAL = { diff --git a/src/i18n/locales/en.js b/src/i18n/locales/en.js index 8304eb1..cebfac6 100644 --- a/src/i18n/locales/en.js +++ b/src/i18n/locales/en.js @@ -239,6 +239,9 @@ const en = { share: "Share", copy_link: "Copy link", readme: "README", + failed_to_load: "Failed to load. Make sure the link is correct.", + share_info: + "* Sharing this link will not create a live real-time collaboration session.", }, };