mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-08-29 02:25:26 +00:00
update getCommits and clean up
This commit is contained in:
@@ -34,15 +34,14 @@ export async function get(gistId) {
|
||||
}
|
||||
|
||||
export async function getCommits(gistId, perPage = 20, page = 1) {
|
||||
const res = await octokit.request(
|
||||
`GET /gists/${gistId}/commits?per_page=${perPage}&page=${page}`,
|
||||
{
|
||||
gist_id: gistId,
|
||||
headers: {
|
||||
"X-GitHub-Api-Version": "2022-11-28",
|
||||
},
|
||||
const res = await axios.get(`${baseUrl}/gists/${gistId}/commits`, {
|
||||
params: {
|
||||
per_page: perPage,
|
||||
page,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
console.log(res)
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import {
|
||||
IconChevronRight,
|
||||
IconChevronLeft,
|
||||
} from "@douyinfe/semi-icons";
|
||||
import * as gists from "../../../api/gists";
|
||||
import { getCommits } from "../../../api/gists";
|
||||
import moment from "moment";
|
||||
|
||||
export default function Revisions({ open }) {
|
||||
@@ -20,9 +20,8 @@ export default function Revisions({ open }) {
|
||||
const getRevisions = async (gistId) => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const gist = await gists.getCommits(gistId);
|
||||
setRevisions(gist);
|
||||
console.log(gist);
|
||||
const { data } = await getCommits(gistId);
|
||||
setRevisions(data);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
Toast.error(t("oops_smth_went_wrong"));
|
||||
|
@@ -287,25 +287,24 @@ export default function WorkSpace() {
|
||||
|
||||
const loadFromGist = async (shareId) => {
|
||||
try {
|
||||
const gist = await get(shareId);
|
||||
const diagramSrc = gist.files["share.json"].content;
|
||||
const d = JSON.parse(diagramSrc);
|
||||
setGistId(shareId);
|
||||
const { data } = await get(shareId);
|
||||
const parsedDiagram = JSON.parse(data.files["share.json"].content);
|
||||
setUndoStack([]);
|
||||
setRedoStack([]);
|
||||
setGistId(shareId);
|
||||
setLoadedFromGistId(shareId);
|
||||
setDatabase(d.database);
|
||||
setTitle(d.title);
|
||||
setTables(d.tables);
|
||||
setRelationships(d.relationships);
|
||||
setNotes(d.notes);
|
||||
setAreas(d.subjectAreas);
|
||||
setTransform(d.transform);
|
||||
if (databases[d.database].hasTypes) {
|
||||
setTypes(d.types ?? []);
|
||||
setDatabase(parsedDiagram.database);
|
||||
setTitle(parsedDiagram.title);
|
||||
setTables(parsedDiagram.tables);
|
||||
setRelationships(parsedDiagram.relationships);
|
||||
setNotes(parsedDiagram.notes);
|
||||
setAreas(parsedDiagram.subjectAreas);
|
||||
setTransform(parsedDiagram.transform);
|
||||
if (databases[parsedDiagram.database].hasTypes) {
|
||||
setTypes(parsedDiagram.types ?? []);
|
||||
}
|
||||
if (databases[d.database].hasEnums) {
|
||||
setEnums(d.enums ?? []);
|
||||
if (databases[parsedDiagram.database].hasEnums) {
|
||||
setEnums(parsedDiagram.enums ?? []);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
Reference in New Issue
Block a user