🐛 fix(vscode): 修复评论全量接口被误分页导致审查反馈卡住
This commit is contained in:
1 parent
8d70ee1659
commit
3134201243
7 files changed
+71
-122
No files matched your search
+8
-40
@@ -235,33 +235,7 @@ export async function listAllRepoComments(opts: {
|
||||
}
|
||||
|
||||
/**
|
||||
* 单页拉取某工单评论。Gitea 默认旧→新,末页才是最新 state JSON 所在。
|
||||
*/
|
||||
export async function listIssueCommentsPage(opts: {
|
||||
host: string
|
||||
token: string
|
||||
owner: string
|
||||
repo: string
|
||||
index: number
|
||||
page: number
|
||||
}): Promise<GiteaComment[]> {
|
||||
const url = new URL(
|
||||
`${baseUrl(opts.host)}/repos/${opts.owner}/${opts.repo}/issues/${opts.index}/comments`,
|
||||
)
|
||||
url.searchParams.set('limit', String(PAGE_SIZE))
|
||||
url.searchParams.set('page', String(opts.page))
|
||||
|
||||
const res = await fetch(url.toString(), { headers: authHeaders(opts.token) })
|
||||
await ensureOk(res)
|
||||
const batch = await res.json() as GiteaComment[]
|
||||
return Array.isArray(batch) ? batch : []
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches comments for a single issue via
|
||||
* `/repos/{owner}/{repo}/issues/{index}/comments`. Paginated until a short
|
||||
* page is returned. Used when we need the freshest view of one issue's
|
||||
* state-JSON comment (e.g. mutating the last comment in place).
|
||||
* 单个工单的评论接口一次返回全部评论,只支持 since / before 时间筛选。
|
||||
*/
|
||||
export async function listIssueComments(opts: {
|
||||
host: string
|
||||
@@ -270,19 +244,13 @@ export async function listIssueComments(opts: {
|
||||
repo: string
|
||||
index: number
|
||||
}): Promise<GiteaComment[]> {
|
||||
const out: GiteaComment[] = []
|
||||
let page = 1
|
||||
|
||||
while (true) {
|
||||
const batch = await listIssueCommentsPage({ ...opts, page })
|
||||
if (batch.length === 0)
|
||||
break
|
||||
out.push(...batch)
|
||||
if (batch.length < PAGE_SIZE)
|
||||
break
|
||||
page += 1
|
||||
}
|
||||
return out
|
||||
const url = new URL(
|
||||
`${baseUrl(opts.host)}/repos/${opts.owner}/${opts.repo}/issues/${opts.index}/comments`,
|
||||
)
|
||||
const res = await fetch(url.toString(), { headers: authHeaders(opts.token) })
|
||||
await ensureOk(res)
|
||||
const batch = await res.json() as GiteaComment[]
|
||||
return Array.isArray(batch) ? batch : []
|
||||
}
|
||||
|
||||
export async function postIssueComment(opts: {
|
||||
|
||||
Reference in new issue
Block a user