Handle source browse when first page is also the last page (#436)

In case the first page was also the last page, there is no next page that can be fetched.
On large screens, where the initial pages to fetch are 2, this resulted in an endless loading screen
This commit is contained in:
schroda
2023-10-29 20:51:53 +01:00
committed by GitHub
parent 529fcf2d25
commit a638333684

View File

@@ -955,7 +955,9 @@ export class RequestManager {
getVariablesFor(0),
);
const areInitialPagesFetched = cachedResults.length >= initialPages;
const areInitialPagesFetched =
cachedResults.length >= initialPages ||
(!!cachedResults.length && !cachedResults[cachedResults.length - 1].data?.fetchSourceManga.hasNextPage);
const isResultForCurrentInput = result?.forInput === JSON.stringify(getVariablesFor(0));
const lastPage = cachedPages.size ? Math.max(...cachedPages) : input.page;
const nextPage = isResultForCurrentInput ? result.size : lastPage;