update getCommits and clean up

This commit is contained in:
1ilit
2025-07-13 16:42:15 +04:00
parent d17c552424
commit 59dd4e0c4d
3 changed files with 24 additions and 27 deletions

View File

@@ -34,15 +34,14 @@ export async function get(gistId) {
} }
export async function getCommits(gistId, perPage = 20, page = 1) { export async function getCommits(gistId, perPage = 20, page = 1) {
const res = await octokit.request( const res = await axios.get(`${baseUrl}/gists/${gistId}/commits`, {
`GET /gists/${gistId}/commits?per_page=${perPage}&page=${page}`, params: {
{ per_page: perPage,
gist_id: gistId, page,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
},
}, },
); });
console.log(res)
return res.data; return res.data;
} }

View File

@@ -7,7 +7,7 @@ import {
IconChevronRight, IconChevronRight,
IconChevronLeft, IconChevronLeft,
} from "@douyinfe/semi-icons"; } from "@douyinfe/semi-icons";
import * as gists from "../../../api/gists"; import { getCommits } from "../../../api/gists";
import moment from "moment"; import moment from "moment";
export default function Revisions({ open }) { export default function Revisions({ open }) {
@@ -20,9 +20,8 @@ export default function Revisions({ open }) {
const getRevisions = async (gistId) => { const getRevisions = async (gistId) => {
setIsLoading(true); setIsLoading(true);
try { try {
const gist = await gists.getCommits(gistId); const { data } = await getCommits(gistId);
setRevisions(gist); setRevisions(data);
console.log(gist);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
Toast.error(t("oops_smth_went_wrong")); Toast.error(t("oops_smth_went_wrong"));

View File

@@ -287,25 +287,24 @@ export default function WorkSpace() {
const loadFromGist = async (shareId) => { const loadFromGist = async (shareId) => {
try { try {
const gist = await get(shareId); const { data } = await get(shareId);
const diagramSrc = gist.files["share.json"].content; const parsedDiagram = JSON.parse(data.files["share.json"].content);
const d = JSON.parse(diagramSrc);
setGistId(shareId);
setUndoStack([]); setUndoStack([]);
setRedoStack([]); setRedoStack([]);
setGistId(shareId);
setLoadedFromGistId(shareId); setLoadedFromGistId(shareId);
setDatabase(d.database); setDatabase(parsedDiagram.database);
setTitle(d.title); setTitle(parsedDiagram.title);
setTables(d.tables); setTables(parsedDiagram.tables);
setRelationships(d.relationships); setRelationships(parsedDiagram.relationships);
setNotes(d.notes); setNotes(parsedDiagram.notes);
setAreas(d.subjectAreas); setAreas(parsedDiagram.subjectAreas);
setTransform(d.transform); setTransform(parsedDiagram.transform);
if (databases[d.database].hasTypes) { if (databases[parsedDiagram.database].hasTypes) {
setTypes(d.types ?? []); setTypes(parsedDiagram.types ?? []);
} }
if (databases[d.database].hasEnums) { if (databases[parsedDiagram.database].hasEnums) {
setEnums(d.enums ?? []); setEnums(parsedDiagram.enums ?? []);
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);