fix: handle paginated pull request files page

This commit is contained in:
EnixCoda 2026-01-16 22:13:48 +08:00
parent 08bb716ef4
commit 68915bfac4
3 changed files with 14 additions and 5 deletions

View file

@ -148,10 +148,13 @@ export async function getPullPageDocuments(
userName: string,
repoName: string,
pullId: string,
document?: Document,
preset?: {
url: string
document: Document
},
) {
if (document) {
return continuousLoadFragmentedPages(window.location.href, document)
if (preset) {
return continuousLoadFragmentedPages(preset.url, preset.document)
}
// Response of this contains view of few files but is not complete.
return continuousLoadFragmentedPagesFromUrl(`/${userName}/${repoName}/pull/${pullId}/files`)

View file

@ -42,7 +42,12 @@ export async function getPullRequestTreeData(
userName,
repoName,
pullId,
isInPullFilesPage() ? document : undefined,
isInPullFilesPage()
? {
url: window.location.href,
document,
}
: undefined,
)
const diffSummaryMap = resolveDiffSummaryMap(docs)

View file

@ -109,7 +109,8 @@ export async function continuousLoadFragmentedPages(
const src = fragment.getAttribute('src')
if (src) {
// Using `src` without origin below would fail in Firefox if the src is an absolute path
return await continuousLoadFragmentedPagesFromUrl(src, docs)
// do NOT return here because we need to preserve the first `url` for the final return value
await continuousLoadFragmentedPagesFromUrl(src, docs)
}
}
return [new URL(url).pathname, docs]