From d93ff92cc95f9e68c8fc184c25f35545415d7d5b Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 16 Aug 2025 08:11:44 +0300 Subject: [PATCH] Update parsers and fix some deprecations --- .../koitharu/kotatsu/explore/domain/ExploreRepository.kt | 6 +++--- .../org/koitharu/kotatsu/list/ui/MangaListViewModel.kt | 3 ++- .../org/koitharu/kotatsu/local/data/LocalMangaRepository.kt | 5 +++-- .../org/koitharu/kotatsu/search/domain/SearchV2Helper.kt | 2 +- .../koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt | 4 ++-- gradle/libs.versions.toml | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/domain/ExploreRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/domain/ExploreRepository.kt index 76a0d46d8..da24bbb57 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/domain/ExploreRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/domain/ExploreRepository.kt @@ -35,7 +35,7 @@ class ExploreRepository @Inject constructor( val details = runCatchingCancellable { mangaRepositoryFactory.create(manga.source).getDetails(manga) }.getOrNull() ?: continue - if ((settings.isSuggestionsExcludeNsfw && details.isNsfw) || details in tagsBlacklist) { + if ((settings.isSuggestionsExcludeNsfw && details.isNsfw()) || details in tagsBlacklist) { continue } return details @@ -55,7 +55,7 @@ class ExploreRepository @Inject constructor( val details = runCatchingCancellable { mangaRepositoryFactory.create(manga.source).getDetails(manga) }.getOrNull() ?: continue - if ((skipNsfw && details.isNsfw) || details in tagsBlacklist) { + if ((skipNsfw && details.isNsfw()) || details in tagsBlacklist) { continue } return details @@ -80,7 +80,7 @@ class ExploreRepository @Inject constructor( filter = MangaListFilter(tags = setOfNotNull(tag)), ).asArrayList() if (settings.isSuggestionsExcludeNsfw) { - list.removeAll { it.isNsfw } + list.removeAll { it.isNsfw() } } if (blacklist.isNotEmpty()) { list.removeAll { manga -> manga in blacklist } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/MangaListViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/MangaListViewModel.kt index 55ed61bda..a45da3bb1 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/MangaListViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/MangaListViewModel.kt @@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.plus +import org.koitharu.kotatsu.core.model.isNsfw import org.koitharu.kotatsu.core.parser.MangaDataRepository import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.core.prefs.ListMode @@ -45,7 +46,7 @@ abstract class MangaListViewModel( abstract fun onRetry() protected fun List.skipNsfwIfNeeded() = if (settings.isNsfwContentDisabled) { - filterNot { it.isNsfw } + filterNot { it.isNsfw() } } else { this } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/LocalMangaRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/LocalMangaRepository.kt index 6d5fa4fab..285a5f7af 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/LocalMangaRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/LocalMangaRepository.kt @@ -12,6 +12,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.runInterruptible import org.koitharu.kotatsu.core.model.LocalMangaSource import org.koitharu.kotatsu.core.model.isLocal +import org.koitharu.kotatsu.core.model.isNsfw import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.core.util.AlphanumComparator @@ -94,7 +95,7 @@ class LocalMangaRepository @Inject constructor( } val list = getRawList() if (settings.isNsfwContentDisabled) { - list.removeAll { it.manga.isNsfw } + list.removeAll { it.manga.isNsfw() } } if (filter != null) { val query = filter.query @@ -109,7 +110,7 @@ class LocalMangaRepository @Inject constructor( } filter.contentRating.singleOrNull()?.let { contentRating -> val isNsfw = contentRating == ContentRating.ADULT - list.retainAll { it.manga.isNsfw == isNsfw } + list.retainAll { it.manga.isNsfw() == isNsfw } } if (!query.isNullOrEmpty() && order == SortOrder.RELEVANCE) { list.sortBy { it.manga.title.levenshteinDistance(query) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/search/domain/SearchV2Helper.kt b/app/src/main/kotlin/org/koitharu/kotatsu/search/domain/SearchV2Helper.kt index b7553d572..b9828df9f 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/search/domain/SearchV2Helper.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/search/domain/SearchV2Helper.kt @@ -76,7 +76,7 @@ class SearchV2Helper @AssistedInject constructor( private fun MutableList.postFilter(query: String, kind: SearchKind) { if (settings.isNsfwContentDisabled) { - removeAll { it.isNsfw } + removeAll { it.isNsfw() } } when (kind) { SearchKind.TITLE -> retainAll { m -> diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt b/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt index 96f30714d..0dda6d100 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt @@ -229,7 +229,7 @@ class SuggestionsWorker @AssistedInject constructor( if (details.rating > 0 && details.rating < RATING_MIN) { continue } - if (details.isNsfw && (appSettings.isSuggestionsExcludeNsfw || appSettings.isNsfwContentDisabled)) { + if (details.isNsfw() && (appSettings.isSuggestionsExcludeNsfw || appSettings.isNsfwContentDisabled)) { continue } if (details in tagsBlacklist) { @@ -277,7 +277,7 @@ class SuggestionsWorker @AssistedInject constructor( filter = MangaListFilter(tags = setOfNotNull(tag)), ).asArrayList() if (appSettings.isSuggestionsExcludeNsfw) { - list.removeAll { it.isNsfw } + list.removeAll { it.isNsfw() } } if (blacklist.isNotEmpty()) { list.removeAll { manga -> manga in blacklist } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cab8fb27b..1c2f12924 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -34,7 +34,7 @@ material = "1.14.0-alpha03" moshi = "1.15.2" okhttp = "4.12.0" okio = "3.12.0" -parsers = "6fb4cc608c" +parsers = "fd0df2414e" preference = "1.2.1" recyclerview = "1.4.0" room = "2.7.2"