Fix search pagination
This commit is contained in:
@@ -34,7 +34,7 @@ open class MangaLibRepository(loaderContext: MangaLoaderContext) :
|
|||||||
tag: MangaTag?
|
tag: MangaTag?
|
||||||
): List<Manga> {
|
): List<Manga> {
|
||||||
if (!query.isNullOrEmpty()) {
|
if (!query.isNullOrEmpty()) {
|
||||||
return search(query)
|
return if (offset == 0) search(query) else emptyList()
|
||||||
}
|
}
|
||||||
val page = (offset / 60f).toIntUp()
|
val page = (offset / 60f).toIntUp()
|
||||||
val url = buildString {
|
val url = buildString {
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ class RemoteRepositoryTest(source: MangaSource) : KoinTest {
|
|||||||
val list = runBlocking { repo.getList(0, query = "tail") }
|
val list = runBlocking { repo.getList(0, query = "tail") }
|
||||||
Assert.assertFalse("List is empty", list.isEmpty())
|
Assert.assertFalse("List is empty", list.isEmpty())
|
||||||
Assert.assertTrue("Mangas are not distinct", list.isDistinctBy { it.id })
|
Assert.assertTrue("Mangas are not distinct", list.isDistinctBy { it.id })
|
||||||
|
val nextList = runBlocking { repo.getList(list.size, query = "tail") }
|
||||||
|
Assert.assertNotEquals("Search pagination is broken", list, nextList)
|
||||||
val item = list.random()
|
val item = list.random()
|
||||||
AssertX.assertUrlRelative("Url is not relative", item.url)
|
AssertX.assertUrlRelative("Url is not relative", item.url)
|
||||||
AssertX.assertContentType("Bad cover at ${item.url}", item.coverUrl, "image/*")
|
AssertX.assertContentType("Bad cover at ${item.url}", item.coverUrl, "image/*")
|
||||||
|
|||||||
Reference in New Issue
Block a user