Skip to content

Commit 10962ca

Browse files
committed
fix: Remove unused import
1 parent 77abc63 commit 10962ca

File tree

1 file changed

+25
-17
lines changed
  • src/app/(default)/r/[owner]/[repo]/post

1 file changed

+25
-17
lines changed

src/app/(default)/r/[owner]/[repo]/post/page.tsx

+25-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import {useEffect, useState} from "react";
44
import usePageContext from "@/store/usePageContext";
55
import {Form, useForm} from "@mantine/form";
6-
import {CommitModel, DataProductPostParam} from "@/server/types";
6+
import {BranchModel, CommitModel, DataProductPostParam} from "@/server/types";
77
import {RepoApi} from "@/server/RepoApi";
88
import {AppWrite} from "@/server/Client";
99
import {
@@ -20,6 +20,7 @@ import {
2020
} from "@mantine/core";
2121
import {notifications} from "@mantine/notifications";
2222
import {ProductApi} from "@/server/ProductApi";
23+
import {debounce} from "lodash";
2324

2425
export default function ProductPostPage(){
2526
const context = usePageContext();
@@ -28,29 +29,36 @@ export default function ProductPostPage(){
2829
const [Publishing, setPublishing] = useState(false);
2930
const repo_api = new RepoApi();
3031
const product_api = new ProductApi();
31-
useEffect(() => {
32+
const Init = debounce(async ()=>{
3233
if (context.repoCtx){
3334
const {owner, repoName} = context.repoCtx;
3435
setParma({owner,repo: repoName})
35-
for(const idx in context.repoCtx.branches) {
36-
const branch = context.repoCtx.branches[idx];
36+
const btch = await repo_api.Bhtc(owner, repoName);
37+
const branches = Object.keys(btch).map((value)=>{
38+
return JSON.parse(value) as BranchModel
39+
});
40+
for(const idx in branches) {
41+
const branch = branches[idx];
3742
repo_api.OneCommit(owner,repoName, branch.name, branch.head)
38-
.then((res) => {
39-
if (res.status === 200) {
40-
const json:AppWrite<CommitModel> = JSON.parse(res.data);
41-
if (json.code === 200 && json.data) {
42-
setHeads((prev) => {
43-
if (prev.find((item) => item.id === json.data!.id)) {
44-
return prev;
45-
}else {
46-
return [...prev, json.data!];
47-
}
48-
});
43+
.then((res) => {
44+
if (res.status === 200) {
45+
const json:AppWrite<CommitModel> = JSON.parse(res.data);
46+
if (json.code === 200 && json.data) {
47+
setHeads((prev) => {
48+
if (prev.find((item) => item.id === json.data!.id)) {
49+
return prev;
50+
}else {
51+
return [...prev, json.data!];
52+
}
53+
});
54+
}
4955
}
50-
}
51-
})
56+
})
5257
}
5358
}
59+
},300)
60+
useEffect(() => {
61+
Init()
5462
}, []);
5563
const form = useForm({
5664
mode: "uncontrolled",

0 commit comments

Comments
 (0)