Skip to content

Commit

Permalink
Fix default category (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Syer10 authored Jun 9, 2024
1 parent 5123653 commit 2599743
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/all/tachidesk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ext {
extName = 'Suwayomi'
pkgNameSuffix = 'all.tachidesk'
extClass = '.Tachidesk'
extVersionCode = 13
extVersionCode = 14
}

apply from: "$rootDir/common.gradle"
Expand Down
3 changes: 1 addition & 2 deletions src/all/tachidesk/graphql/Manga.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -388,11 +389,24 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() {
val tagFilterIncludeMode = tagModes[tagFilterIncludeModeIndex]
val tagFilterExcludeMode = tagModes[tagFilterExcludeModeIndex]

val filterInput = mutableListOf<MangaFilterInput>()
// 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<Triple<Boolean, String, List<String>>>()
Expand All @@ -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
Expand Down Expand Up @@ -443,7 +457,7 @@ class Tachidesk : ConfigurableSource, UnmeteredSource, HttpSource() {
)
else -> null
}
}.toMutableList()
}

// Filter according to search terms.
if (query.isNotEmpty()) {
Expand Down Expand Up @@ -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 ->
Expand Down

0 comments on commit 2599743

Please sign in to comment.