Fix Kavita search pagination
This commit is contained in:
@@ -2,7 +2,7 @@ ext {
|
|||||||
kmkVersionCode = 1
|
kmkVersionCode = 1
|
||||||
extName = 'Kavita'
|
extName = 'Kavita'
|
||||||
extClass = '.KavitaFactory'
|
extClass = '.KavitaFactory'
|
||||||
extVersionCode = 33
|
extVersionCode = 34
|
||||||
isNsfw = false
|
isNsfw = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2030,7 +2030,7 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
|
|||||||
}
|
}
|
||||||
|
|
||||||
val mangaList = filteredSeries.map { helper.createSeriesDto(it, apiUrl, apiKey) }
|
val mangaList = filteredSeries.map { helper.createSeriesDto(it, apiUrl, apiKey) }
|
||||||
MangasPage(mangaList, false)
|
MangasPage(mangaList, helper.hasNextPage(response, result.size))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(LOG_TAG, "Error parsing search results", e)
|
Log.e(LOG_TAG, "Error parsing search results", e)
|
||||||
throw IOException(intl["check_version"], e)
|
throw IOException(intl["check_version"], e)
|
||||||
|
|||||||
@@ -45,14 +45,14 @@ class KavitaHelper {
|
|||||||
|
|
||||||
val seriesMap = SeriesMapper()
|
val seriesMap = SeriesMapper()
|
||||||
|
|
||||||
fun hasNextPage(response: Response): Boolean {
|
fun hasNextPage(response: Response, itemCount: Int? = null, pageSize: Int = 20): Boolean {
|
||||||
val paginationHeader = response.header("Pagination")
|
val paginationHeader = response.header("Pagination")
|
||||||
var hasNextPage = false
|
|
||||||
if (!paginationHeader.isNullOrEmpty()) {
|
if (!paginationHeader.isNullOrEmpty()) {
|
||||||
val paginationInfo = json.decodeFromString<PaginationInfo>(paginationHeader)
|
val paginationInfo = json.decodeFromString<PaginationInfo>(paginationHeader)
|
||||||
hasNextPage = paginationInfo.currentPage < paginationInfo.totalPages
|
return paginationInfo.currentPage < paginationInfo.totalPages
|
||||||
}
|
}
|
||||||
return hasNextPage
|
|
||||||
|
return itemCount != null && itemCount >= pageSize
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getIdFromUrl(url: String): Int {
|
fun getIdFromUrl(url: String): Int {
|
||||||
|
|||||||
Reference in New Issue
Block a user