clean up sharing

This commit is contained in:
1ilit
2025-04-05 15:41:26 +04:00
parent 24c77a95e9
commit 1367ef3745
4 changed files with 34 additions and 4 deletions

View File

@@ -66,6 +66,7 @@ export default function Share({ title, setModal }) {
useEffect(() => {
const updateOrGenerateLink = async () => {
setLoading(true);
try {
setLoading(true);
if (!gistId || gistId === "") {

View File

@@ -1,5 +1,33 @@
import { useContext, useEffect, useState } from "react";
import { IdContext } from "../../Workspace";
import { useTranslation } from "react-i18next";
import { Button, Spin } from "@douyinfe/semi-ui";
import { IconPlus } from "@douyinfe/semi-icons";
export default function Revisions() {
const { gistId } = useContext(IdContext);
const { t } = useTranslation();
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
setIsLoading(false);
}, []);
if (gistId && isLoading) {
return (
<div className="text-blue-500 text-center">
<Spin size="middle" />
<div>{t("loading")}</div>
</div>
);
}
return (
<div className="sidesheet-theme">Revisions</div>
)
<div className="mx-5">
<Button icon={<IconPlus />} block onClick={() => {}}>
{t("record_version")}
</Button>
{!gistId && <div className="my-3">{t("no_saved_revisions")}</div>}
</div>
);
}

View File

@@ -287,8 +287,8 @@ export default function WorkSpace() {
const loadFromGist = async (shareId) => {
try {
const res = await get(shareId);
const diagramSrc = res.data.files["share.json"].content;
const gist = await get(shareId);
const diagramSrc = gist.files["share.json"].content;
const d = JSON.parse(diagramSrc);
setGistId(shareId);
setUndoStack([]);

View File

@@ -259,6 +259,7 @@ const en = {
label: "Label",
many_side_label: "Many(n) side label",
revisions: "Revisions",
no_saved_revisions: "No saved revisions",
},
};