From fc204bd93a44c342fd21b7eb3b81d13f841b9f1c Mon Sep 17 00:00:00 2001 From: TheOneMaster <25909677+TheOneMaster@users.noreply.github.com> Date: Sat, 11 Sep 2021 13:15:53 +0200 Subject: [PATCH] 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 --- src/all/mangadex/build.gradle | 2 +- .../extension/all/mangadex/MangaDexFilters.kt | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index 8feee32d8..41b38de89 100644 --- a/src/all/mangadex/build.gradle +++ b/src/all/mangadex/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'MangaDex' pkgNameSuffix = 'all.mangadex' extClass = '.MangaDexFactory' - extVersionCode = 131 + extVersionCode = 132 containsNsfw = true } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt index 36f1ac0e5..5919e33e2 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt @@ -191,12 +191,13 @@ class MangaDexFilters { Filter.Select("Excluded tags mode", arrayOf("And", "Or"), 1) val sortableList = listOf( - Pair("Number of follows", ""), + Pair("Number of follows", "followedCount"), Pair("Manga created at", "createdAt"), Pair("Manga info updated at", "updatedAt"), + Pair("Relevant manga", "relevance") ) - class SortFilter(sortables: Array) : Filter.Sort("Sort", sortables, Selection(1, false)) + class SortFilter(sortables: Array) : Filter.Sort("Sort", sortables, Selection(0, false)) internal fun addFiltersToUrl(url: HttpUrl.Builder, filters: FilterList): String { url.apply { @@ -256,14 +257,12 @@ class MangaDexFilters { } is SortFilter -> { if (filter.state != null) { - if (filter.state!!.index != 0) { - val query = sortableList[filter.state!!.index].second - val value = when (filter.state!!.ascending) { - true -> "asc" - false -> "desc" - } - addQueryParameter("order[$query]", value) + val query = sortableList[filter.state!!.index].second + val value = when (filter.state!!.ascending) { + true -> "asc" + false -> "desc" } + addQueryParameter("order[$query]", value) } } is TagList -> {