From 380b7594f577a8375096de071cf13e6f937fd3a0 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Fri, 4 Jun 2021 19:38:57 +0800 Subject: [PATCH] filter series by in progress and read (#7446) --- src/all/komga/CHANGELOG.md | 8 ++++++ src/all/komga/build.gradle | 2 +- .../tachiyomi/extension/all/komga/Komga.kt | 28 ++++++++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/all/komga/CHANGELOG.md b/src/all/komga/CHANGELOG.md index 8d3c50678..f8fa75ef5 100644 --- a/src/all/komga/CHANGELOG.md +++ b/src/all/komga/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.2.27 + +Minimum Komga version required: `0.97.0` + +### Fix + +* filter series by read or in progress + ## 1.2.26 Minimum Komga version required: `0.87.4` diff --git a/src/all/komga/build.gradle b/src/all/komga/build.gradle index d2801195d..4b755f7f5 100644 --- a/src/all/komga/build.gradle +++ b/src/all/komga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Komga' pkgNameSuffix = 'all.komga' extClass = '.KomgaFactory' - extVersionCode = 26 + extVersionCode = 27 libVersion = '1.2' } diff --git a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt index d36fc93e8..0d74e44f5 100644 --- a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt +++ b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt @@ -69,12 +69,22 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() { filters.forEach { filter -> when (filter) { - is UnreadOnly -> { + is UnreadFilter -> { if (filter.state) { url.addQueryParameter("read_status", "UNREAD") url.addQueryParameter("read_status", "IN_PROGRESS") } } + is InProgressFilter -> { + if (filter.state) { + url.addQueryParameter("read_status", "IN_PROGRESS") + } + } + is ReadFilter -> { + if (filter.state) { + url.addQueryParameter("read_status", "READ") + } + } is LibraryGroup -> { val libraryToInclude = mutableListOf() filter.state.forEach { content -> @@ -286,7 +296,9 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() { private class SeriesSort : Filter.Sort("Sort", arrayOf("Alphabetically", "Date added", "Date updated"), Selection(0, true)) private class StatusFilter(name: String) : Filter.CheckBox(name, false) private class StatusGroup(filters: List) : Filter.Group("Status", filters) - private class UnreadOnly : Filter.CheckBox("Unread only", false) + private class UnreadFilter : Filter.CheckBox("Unread", false) + private class InProgressFilter : Filter.CheckBox("In Progress", false) + private class ReadFilter : Filter.CheckBox("Read", false) private class GenreFilter(genre: String) : Filter.CheckBox(genre, false) private class GenreGroup(genres: List) : Filter.Group("Genres", genres) private class TagFilter(tag: String) : Filter.CheckBox(tag, false) @@ -306,17 +318,19 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() { override fun getFilterList(): FilterList { val filters = try { mutableListOf>( - UnreadOnly(), + UnreadFilter(), + InProgressFilter(), + ReadFilter(), TypeSelect(), CollectionSelect(listOf(CollectionFilterEntry("None")) + collections.map { CollectionFilterEntry(it.name, it.id) }), - LibraryGroup(libraries.map { LibraryFilter(it.id, it.name) }.sortedBy { it.name.toLowerCase() }), + LibraryGroup(libraries.map { LibraryFilter(it.id, it.name) }.sortedBy { it.name.toLowerCase(Locale.ROOT) }), StatusGroup(listOf("Ongoing", "Ended", "Abandoned", "Hiatus").map { StatusFilter(it) }), GenreGroup(genres.map { GenreFilter(it) }), TagGroup(tags.map { TagFilter(it) }), PublisherGroup(publishers.map { PublisherFilter(it) }) - ).also { - it.addAll(authors.map { (role, authors) -> AuthorGroup(role, authors.map { AuthorFilter(it) }) }) - it.add(SeriesSort()) + ).also { list -> + list.addAll(authors.map { (role, authors) -> AuthorGroup(role, authors.map { AuthorFilter(it) }) }) + list.add(SeriesSort()) } } catch (e: Exception) { Log.e(LOG_TAG, "error while creating filter list", e)