Handle incorrect links and corrupted files

This commit is contained in:
1ilit 2024-09-01 21:14:18 +04:00
parent 47ef0dfa82
commit fcf2251e9b
5 changed files with 10 additions and 5 deletions

View File

@ -1084,7 +1084,7 @@ export default function ControlPanel({
data: result, data: result,
extension: "md", extension: "md",
})); }));
} },
}, },
], ],
function: () => {}, function: () => {},
@ -1604,6 +1604,8 @@ export default function ControlPanel({
return t("saving"); return t("saving");
case State.ERROR: case State.ERROR:
return t("failed_to_save"); return t("failed_to_save");
case State.FAILED_TO_LOAD:
return t("failed_to_load");
default: default:
return ""; return "";
} }

View File

@ -146,10 +146,7 @@ export default function Share({ title }) {
</Button> </Button>
</div> </div>
<hr className="opacity-20 mt-3 mb-1" /> <hr className="opacity-20 mt-3 mb-1" />
<div className="text-xs"> <div className="text-xs">{t("share_info")}</div>
* Sharing this link will not create a live real-time collaboration
session
</div>
</div> </div>
); );
} }

View File

@ -356,6 +356,7 @@ export default function WorkSpace() {
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
setSaveState(State.FAILED_TO_LOAD);
} }
}, },
[ [
@ -369,6 +370,7 @@ export default function WorkSpace() {
setTransform, setTransform,
setRedoStack, setRedoStack,
setUndoStack, setUndoStack,
setSaveState,
], ],
); );

View File

@ -77,6 +77,7 @@ export const State = {
SAVED: 2, SAVED: 2,
LOADING: 3, LOADING: 3,
ERROR: 4, ERROR: 4,
FAILED_TO_LOAD: 5,
}; };
export const MODAL = { export const MODAL = {

View File

@ -239,6 +239,9 @@ const en = {
share: "Share", share: "Share",
copy_link: "Copy link", copy_link: "Copy link",
readme: "README", 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.",
}, },
}; };