From 2599743f6f7c4920726bb3504691c848ad420350 Mon Sep 17 00:00:00 2001 From: Mitchell Syer Date: Sat, 8 Jun 2024 22:36:58 -0400 Subject: [PATCH] Fix default category (#4) --- src/all/tachidesk/build.gradle | 2 +- src/all/tachidesk/graphql/Manga.graphql | 3 +- .../extension/all/tachidesk/Tachidesk.kt | 28 ++++++++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/all/tachidesk/build.gradle b/src/all/tachidesk/build.gradle index d7681f0..53b4676 100644 --- a/src/all/tachidesk/build.gradle +++ b/src/all/tachidesk/build.gradle @@ -7,7 +7,7 @@ ext { extName = 'Suwayomi' pkgNameSuffix = 'all.tachidesk' extClass = '.Tachidesk' - extVersionCode = 13 + extVersionCode = 14 } apply from: "$rootDir/common.gradle" diff --git a/src/all/tachidesk/graphql/Manga.graphql b/src/all/tachidesk/graphql/Manga.graphql index 3e5a242..fb560e2 100644 --- a/src/all/tachidesk/graphql/Manga.graphql +++ b/src/all/tachidesk/graphql/Manga.graphql @@ -22,11 +22,10 @@ mutation GetManga($mangaId: Int!) { } } -query SearchManga($categories: [Int!]!, $filter: [MangaFilterInput!]) { +query SearchManga($filter: [MangaFilterInput!]) { mangas( condition: {inLibrary: true}, filter: { - categoryId: {in: $categories}, and: $filter } ) { diff --git a/src/all/tachidesk/src/eu/kanade/tachiyomi/extension/all/tachidesk/Tachidesk.kt b/src/all/tachidesk/src/eu/kanade/tachiyomi/extension/all/tachidesk/Tachidesk.kt index 362e128..ecfc3f3 100644 --- a/src/all/tachidesk/src/eu/kanade/tachiyomi/extension/all/tachidesk/Tachidesk.kt +++ b/src/all/tachidesk/src/eu/kanade/tachiyomi/extension/all/tachidesk/Tachidesk.kt @@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.extension.all.tachidesk.apollo.SearchMangaQuery import eu.kanade.tachiyomi.extension.all.tachidesk.apollo.fragment.CategoryFragment import eu.kanade.tachiyomi.extension.all.tachidesk.apollo.fragment.ChapterFragment import eu.kanade.tachiyomi.extension.all.tachidesk.apollo.fragment.MangaFragment +import eu.kanade.tachiyomi.extension.all.tachidesk.apollo.type.IntFilterInput import eu.kanade.tachiyomi.extension.all.tachidesk.apollo.type.MangaFilterInput import eu.kanade.tachiyomi.extension.all.tachidesk.apollo.type.MangaStatus import eu.kanade.tachiyomi.extension.all.tachidesk.apollo.type.StringFilterInput @@ -388,11 +389,24 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { val tagFilterIncludeMode = tagModes[tagFilterIncludeModeIndex] val tagFilterExcludeMode = tagModes[tagFilterExcludeModeIndex] + val filterInput = mutableListOf() // Get URLs of categories to search - val categoryIdList = if (currentCategoryId == -1) { - categoryList.map { category -> category.id } - } else { - listOf(currentCategoryId) + if (currentCategoryId >= 0) { + filterInput.add( + MangaFilterInput( + categoryId = Optional.present( + if (currentCategoryId == 0) { + IntFilterInput( + isNull = Optional.present(true) + ) + } else { + IntFilterInput( + equalTo = Optional.present(currentCategoryId) + ) + } + ) + ) + ) } val filterConfigs = mutableListOf>>() @@ -415,7 +429,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { ) } - val filterInput = filterConfigs.mapNotNull { config -> + filterConfigs.mapNotNullTo(filterInput) { config -> val isInclude = config.first val filterMode = config.second val filteredTagList = config.third @@ -443,7 +457,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { ) else -> null } - }.toMutableList() + } // Filter according to search terms. if (query.isNotEmpty()) { @@ -489,7 +503,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() { // Construct a list of all manga in the required categories by querying each one return apolloClient.value.query( - SearchMangaQuery(categoryIdList, optionalFilterInput), + SearchMangaQuery(optionalFilterInput), ) .toFlow() .map { response ->