Skip to content

Commit fcf2251

Browse files
committed
Handle incorrect links and corrupted files
1 parent 47ef0df commit fcf2251

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

src/components/EditorHeader/ControlPanel.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ export default function ControlPanel({
10841084
data: result,
10851085
extension: "md",
10861086
}));
1087-
}
1087+
},
10881088
},
10891089
],
10901090
function: () => {},
@@ -1604,6 +1604,8 @@ export default function ControlPanel({
16041604
return t("saving");
16051605
case State.ERROR:
16061606
return t("failed_to_save");
1607+
case State.FAILED_TO_LOAD:
1608+
return t("failed_to_load");
16071609
default:
16081610
return "";
16091611
}

src/components/EditorHeader/Modal/Share.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ export default function Share({ title }) {
146146
</Button>
147147
</div>
148148
<hr className="opacity-20 mt-3 mb-1" />
149-
<div className="text-xs">
150-
* Sharing this link will not create a live real-time collaboration
151-
session
152-
</div>
149+
<div className="text-xs">{t("share_info")}</div>
153150
</div>
154151
);
155152
}

src/components/Workspace.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ export default function WorkSpace() {
356356
}
357357
} catch (e) {
358358
console.log(e);
359+
setSaveState(State.FAILED_TO_LOAD);
359360
}
360361
},
361362
[
@@ -369,6 +370,7 @@ export default function WorkSpace() {
369370
setTransform,
370371
setRedoStack,
371372
setUndoStack,
373+
setSaveState,
372374
],
373375
);
374376

src/data/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const State = {
7777
SAVED: 2,
7878
LOADING: 3,
7979
ERROR: 4,
80+
FAILED_TO_LOAD: 5,
8081
};
8182

8283
export const MODAL = {

src/i18n/locales/en.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ const en = {
239239
share: "Share",
240240
copy_link: "Copy link",
241241
readme: "README",
242+
failed_to_load: "Failed to load. Make sure the link is correct.",
243+
share_info:
244+
"* Sharing this link will not create a live real-time collaboration session.",
242245
},
243246
};
244247

0 commit comments

Comments
 (0)