diff --git a/public/assets/js/diff-view.js b/public/assets/js/diff-view.js index 45fc2c6e..bf7a2b7a 100644 --- a/public/assets/js/diff-view.js +++ b/public/assets/js/diff-view.js @@ -237,9 +237,10 @@ attributeFilter: ["data-folded", "data-tree-filtered"], }); updateFoldLabels(); - // GitHub loads the next files while scrolling. Press Forgejo's hidden "Show more" link before the end comes into - // view; its handler swaps in a new #diff-incomplete for each page. A loader still there after a while failed or is - // slow, so it is watched again and retried once in view. + // GitHub loads the next files while scrolling. Press Forgejo's hidden "Show more" link while the end is still four + // screens away, so a page is usually loaded before it is reached; its handler swaps in a new #diff-incomplete for + // each page. A link that is busy with another load is tried again shortly; a loader still there after a while failed + // or is slow, so it is watched again and retried once in view. const content = document.getElementById("diff-content-container"); if (content && "IntersectionObserver" in window) { const loader = new IntersectionObserver( @@ -247,11 +248,13 @@ for (const entry of entries) { if (!entry.isIntersecting) continue; loader.unobserve(entry.target); - entry.target.querySelector("#diff-show-more-files:not(.disabled)")?.click(); - setTimeout(() => entry.target.isConnected && loader.observe(entry.target), 5000); + const link = entry.target.querySelector("#diff-show-more-files"); + const busy = link?.classList.contains("disabled"); + if (link && !busy) link.click(); + setTimeout(() => entry.target.isConnected && loader.observe(entry.target), busy ? 300 : 5000); } }, - { rootMargin: "0px 0px 2000px 0px" } + { rootMargin: "0px 0px 400% 0px" } ); const watchIncomplete = () => { const incomplete = document.getElementById("diff-incomplete"); diff --git a/styles/components/issues/pull_review.ts b/styles/components/issues/pull_review.ts index 4ab15975..364a18d2 100644 --- a/styles/components/issues/pull_review.ts +++ b/styles/components/issues/pull_review.ts @@ -40,6 +40,9 @@ const mergeButton = ` `; export default css` + .full.height:has(> .page-content.github-pull-review.files) { + padding-bottom: 0; + } .page-content.repository.view.issue.github-pull-review { & > .ui.container { width: calc(100% - 64px) !important; @@ -50,6 +53,8 @@ export default css` &.files > .ui.container { width: 100% !important; max-width: none !important; + /* GitHub's divider between the file tree and the files runs down to the footer. */ + margin-bottom: 0 !important; } /* GitHub's files tab is full width: title, tabs and diff share a 24px side margin. */ &.files > .ui.container > .issue-title-header, diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 9606009e..2f6da468 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -33,7 +33,10 @@ selectedItem: '', }; diffFileInfo = Object.assign(diffFileInfo, diffData); - diffFileInfo.files.push(...diffDataFiles); + // Every page lists all files of the diff, so a loaded page adds only the files not listed yet. Pushing the + // whole list again grew the tree's data with each page and slowed every later page down. + const knownFiles = new Set(diffFileInfo.files.map(file => file.NameHash)); + diffFileInfo.files.push(...diffDataFiles.filter(file => !knownFiles.has(file.NameHash))); window.config.pageData.diffFileInfo = diffFileInfo; {{end}} @@ -199,16 +202,20 @@ {{end}} - {{if .DiffMetadata.HasNext}} - {{/* GitHub loads the next files while scrolling: diff-view.js presses the hidden "Show more" link. */}} -