fix(frontend): make infinite scroll viewport-relative, stop eager-loading
Lazy load fetched the entire list at once: every list's loader had a "fill the viewport" recursion gated on scrollContainer.scrollHeight <= clientHeight, but <main> is not the scroller (the window/body is), so that condition is always true and it recursed through every page (with a 10-item window, ~all pages fired at once). Move the filling logic into InfiniteScroll and base it on the sentinel's viewport rect instead: load while the sentinel is within 300px of the viewport bottom, re-checked synchronously after each load. This works regardless of which element scrolls and loads only enough pages to reach past the viewport. Drop the per-page recursion (and now-unused scrollContainer refs / tick imports) from the files, trash, tags, categories and pools lists. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -203,12 +203,9 @@
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
// If the loaded content doesn't fill the viewport yet (no scrollbar),
|
||||
// keep loading until it does or there's nothing left.
|
||||
await tick();
|
||||
if (hasMore && scrollContainer && scrollContainer.scrollHeight <= scrollContainer.clientHeight) {
|
||||
void loadMore();
|
||||
}
|
||||
// Viewport filling is handled by InfiniteScroll, which re-checks after each
|
||||
// load — no manual recursion (which over-fetched here because <main> isn't
|
||||
// the scroller, so its scrollHeight never exceeds its clientHeight).
|
||||
}
|
||||
|
||||
function applyFilter(filter: string | null) {
|
||||
|
||||
Reference in New Issue
Block a user