Inf-scroll: Don't add pages when no more results are available.

--- The bad scenario:
A less popular tag like 'kanji' yields only 23 results today. The code continues to increase the page count. We'll either see some blank page glitches at the bottom, or repeated entries being shown.

--- The fix:
Assume that an unfilled page means "no more results" and stop incrementing the page. This seems true based on empirical evidence.
This commit is contained in:
infiinte-persistence 2020-06-15 13:18:15 +02:00 committed by Sean Yesmunt
parent 522c6ddcd6
commit bbda69dc5f

View file

@ -424,7 +424,12 @@ function ClaimListDiscover(props: Props) {
function handleScrollBottom() { function handleScrollBottom() {
if (!loading && infiniteScroll) { if (!loading && infiniteScroll) {
setPage(page + 1); if (claimSearchResult && claimSearchResult.length % CS.PAGE_SIZE === 0) {
// Only increment the page if the current page is full. A partially-filled page probably
// indicates "no more search results" (at least based on my testing). Gating this prevents
// incrementing the page when scrolling upwards.
setPage(page + 1);
}
} }
} }