fix(totalPages): fixed bug showing wrong totalPages

This commit is contained in:
Ritesh Ghosh
2023-08-06 18:48:44 +05:30
parent 6af8285970
commit 96085a32b1
3 changed files with 13 additions and 28 deletions
+4 -9
View File
@@ -28,7 +28,7 @@ async function scrapeAnimeCategory(
category,
currentPage: Number(page),
hasNextPage: false,
totalPages: 0,
totalPages: 1,
};
try {
@@ -56,7 +56,7 @@ async function scrapeAnimeCategory(
: false;
res.totalPages =
parseInt(
Number(
$('.pagination > .page-item a[title="Last"]')
?.attr("href")
?.split("=")
@@ -66,17 +66,12 @@ async function scrapeAnimeCategory(
?.split("=")
.pop() ??
$(".pagination > .page-item.active a")?.text()?.trim()
) || 0;
if (res.totalPages === 0 && !res.hasNextPage) {
res.totalPages = 0;
}
) || 1;
res.animes = extractAnimes($, selector);
if (res.animes.length === 0) {
if (res.animes.length === 0 && !res.hasNextPage) {
res.totalPages = 0;
res.hasNextPage = false;
}
const genreSelector: SelectorType =