Fixed Mangadex sorting issues when filtering (#9020)

* fixed sorting issues

Fixed "Sort by Most Follows" since it was no longer the default, and added relevance sorting to the list of possible sorts

* Fixed Mangadex sorting when browsing

* Changed default sort to Most Followed manga

* Fixed it so that the "Number of follows" is the default sorting filter selected instead of "Manga created at"

* When sorting by ascending for Number of follows, returns manga with the fewest follows instead of default search with no sort

Co-authored-by: nayan <TheOneMaster@users.noreply.github.com>
This commit is contained in:
TheOneMaster 2021-09-11 13:15:53 +02:00 committed by GitHub
parent efa546c94b
commit fc204bd93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'MangaDex' extName = 'MangaDex'
pkgNameSuffix = 'all.mangadex' pkgNameSuffix = 'all.mangadex'
extClass = '.MangaDexFactory' extClass = '.MangaDexFactory'
extVersionCode = 131 extVersionCode = 132
containsNsfw = true containsNsfw = true
} }

View File

@ -191,12 +191,13 @@ class MangaDexFilters {
Filter.Select<String>("Excluded tags mode", arrayOf("And", "Or"), 1) Filter.Select<String>("Excluded tags mode", arrayOf("And", "Or"), 1)
val sortableList = listOf( val sortableList = listOf(
Pair("Number of follows", ""), Pair("Number of follows", "followedCount"),
Pair("Manga created at", "createdAt"), Pair("Manga created at", "createdAt"),
Pair("Manga info updated at", "updatedAt"), Pair("Manga info updated at", "updatedAt"),
Pair("Relevant manga", "relevance")
) )
class SortFilter(sortables: Array<String>) : Filter.Sort("Sort", sortables, Selection(1, false)) class SortFilter(sortables: Array<String>) : Filter.Sort("Sort", sortables, Selection(0, false))
internal fun addFiltersToUrl(url: HttpUrl.Builder, filters: FilterList): String { internal fun addFiltersToUrl(url: HttpUrl.Builder, filters: FilterList): String {
url.apply { url.apply {
@ -256,7 +257,6 @@ class MangaDexFilters {
} }
is SortFilter -> { is SortFilter -> {
if (filter.state != null) { if (filter.state != null) {
if (filter.state!!.index != 0) {
val query = sortableList[filter.state!!.index].second val query = sortableList[filter.state!!.index].second
val value = when (filter.state!!.ascending) { val value = when (filter.state!!.ascending) {
true -> "asc" true -> "asc"
@ -265,7 +265,6 @@ class MangaDexFilters {
addQueryParameter("order[$query]", value) addQueryParameter("order[$query]", value)
} }
} }
}
is TagList -> { is TagList -> {
filter.state.forEach { tag -> filter.state.forEach { tag ->
if (tag.isIncluded()) { if (tag.isIncluded()) {