NHentai | Fixed "Pages" & "Uploaded" Filters (#4678)

Fixed "Pages" & "Uploaded" Filters

- Also removed "isOkayToSort" because I think it's useless... ( might be wrong? )
This commit is contained in:
KenjieDec 2024-08-19 16:27:55 +07:00 committed by Draff
parent 042abd4e93
commit 1302bf5e80
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 9 additions and 7 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'NHentai' extName = 'NHentai'
extClass = '.NHFactory' extClass = '.NHFactory'
extVersionCode = 45 extVersionCode = 46
isNsfw = true isNsfw = true
} }

View File

@ -140,7 +140,6 @@ open class NHentai(
val nhLangSearch = if (nhLang.isBlank()) "" else "language:$nhLang " val nhLangSearch = if (nhLang.isBlank()) "" else "language:$nhLang "
val advQuery = combineQuery(filterList) val advQuery = combineQuery(filterList)
val favoriteFilter = filterList.findInstance<FavoriteFilter>() val favoriteFilter = filterList.findInstance<FavoriteFilter>()
val isOkayToSort = filterList.findInstance<UploadedFilter>()?.state?.isBlank() ?: true
val offsetPage = val offsetPage =
filterList.findInstance<OffsetPageFilter>()?.state?.toIntOrNull()?.plus(page) ?: page filterList.findInstance<OffsetPageFilter>()?.state?.toIntOrNull()?.plus(page) ?: page
@ -157,10 +156,8 @@ open class NHentai(
.addQueryParameter("q", "$query $nhLangSearch$advQuery".ifBlank { "\"\"" }) .addQueryParameter("q", "$query $nhLangSearch$advQuery".ifBlank { "\"\"" })
.addQueryParameter("page", offsetPage.toString()) .addQueryParameter("page", offsetPage.toString())
if (isOkayToSort) { filterList.findInstance<SortFilter>()?.let { f ->
filterList.findInstance<SortFilter>()?.let { f -> url.addQueryParameter("sort", f.toUriPart())
url.addQueryParameter("sort", f.toUriPart())
}
} }
return GET(url.build(), headers) return GET(url.build(), headers)
@ -173,8 +170,13 @@ open class NHentai(
.map(String::trim) .map(String::trim)
.filterNot(String::isBlank) .filterNot(String::isBlank)
.forEach { tag -> .forEach { tag ->
val y = !(filter.name == "Pages" || filter.name == "Uploaded")
if (tag.startsWith("-")) append("-") if (tag.startsWith("-")) append("-")
append(filter.name, ":\"", tag.removePrefix("-"), "\" ") append(filter.name, ':')
if (y) append('"')
append(tag.removePrefix("-"))
if (y) append('"')
append(" ")
} }
} }
} }