Update parsers and fix some deprecations

master
Koitharu 9 months ago
parent 8eda113f3b
commit d93ff92cc9
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -35,7 +35,7 @@ class ExploreRepository @Inject constructor(
val details = runCatchingCancellable { val details = runCatchingCancellable {
mangaRepositoryFactory.create(manga.source).getDetails(manga) mangaRepositoryFactory.create(manga.source).getDetails(manga)
}.getOrNull() ?: continue }.getOrNull() ?: continue
if ((settings.isSuggestionsExcludeNsfw && details.isNsfw) || details in tagsBlacklist) { if ((settings.isSuggestionsExcludeNsfw && details.isNsfw()) || details in tagsBlacklist) {
continue continue
} }
return details return details
@ -55,7 +55,7 @@ class ExploreRepository @Inject constructor(
val details = runCatchingCancellable { val details = runCatchingCancellable {
mangaRepositoryFactory.create(manga.source).getDetails(manga) mangaRepositoryFactory.create(manga.source).getDetails(manga)
}.getOrNull() ?: continue }.getOrNull() ?: continue
if ((skipNsfw && details.isNsfw) || details in tagsBlacklist) { if ((skipNsfw && details.isNsfw()) || details in tagsBlacklist) {
continue continue
} }
return details return details
@ -80,7 +80,7 @@ class ExploreRepository @Inject constructor(
filter = MangaListFilter(tags = setOfNotNull(tag)), filter = MangaListFilter(tags = setOfNotNull(tag)),
).asArrayList() ).asArrayList()
if (settings.isSuggestionsExcludeNsfw) { if (settings.isSuggestionsExcludeNsfw) {
list.removeAll { it.isNsfw } list.removeAll { it.isNsfw() }
} }
if (blacklist.isNotEmpty()) { if (blacklist.isNotEmpty()) {
list.removeAll { manga -> manga in blacklist } list.removeAll { manga -> manga in blacklist }

@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.plus import kotlinx.coroutines.plus
import org.koitharu.kotatsu.core.model.isNsfw
import org.koitharu.kotatsu.core.parser.MangaDataRepository import org.koitharu.kotatsu.core.parser.MangaDataRepository
import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.core.prefs.ListMode import org.koitharu.kotatsu.core.prefs.ListMode
@ -45,7 +46,7 @@ abstract class MangaListViewModel(
abstract fun onRetry() abstract fun onRetry()
protected fun List<Manga>.skipNsfwIfNeeded() = if (settings.isNsfwContentDisabled) { protected fun List<Manga>.skipNsfwIfNeeded() = if (settings.isNsfwContentDisabled) {
filterNot { it.isNsfw } filterNot { it.isNsfw() }
} else { } else {
this this
} }

@ -12,6 +12,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runInterruptible import kotlinx.coroutines.runInterruptible
import org.koitharu.kotatsu.core.model.LocalMangaSource import org.koitharu.kotatsu.core.model.LocalMangaSource
import org.koitharu.kotatsu.core.model.isLocal 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.parser.MangaRepository
import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.core.util.AlphanumComparator import org.koitharu.kotatsu.core.util.AlphanumComparator
@ -94,7 +95,7 @@ class LocalMangaRepository @Inject constructor(
} }
val list = getRawList() val list = getRawList()
if (settings.isNsfwContentDisabled) { if (settings.isNsfwContentDisabled) {
list.removeAll { it.manga.isNsfw } list.removeAll { it.manga.isNsfw() }
} }
if (filter != null) { if (filter != null) {
val query = filter.query val query = filter.query
@ -109,7 +110,7 @@ class LocalMangaRepository @Inject constructor(
} }
filter.contentRating.singleOrNull()?.let { contentRating -> filter.contentRating.singleOrNull()?.let { contentRating ->
val isNsfw = contentRating == ContentRating.ADULT val isNsfw = contentRating == ContentRating.ADULT
list.retainAll { it.manga.isNsfw == isNsfw } list.retainAll { it.manga.isNsfw() == isNsfw }
} }
if (!query.isNullOrEmpty() && order == SortOrder.RELEVANCE) { if (!query.isNullOrEmpty() && order == SortOrder.RELEVANCE) {
list.sortBy { it.manga.title.levenshteinDistance(query) } list.sortBy { it.manga.title.levenshteinDistance(query) }

@ -76,7 +76,7 @@ class SearchV2Helper @AssistedInject constructor(
private fun MutableList<Manga>.postFilter(query: String, kind: SearchKind) { private fun MutableList<Manga>.postFilter(query: String, kind: SearchKind) {
if (settings.isNsfwContentDisabled) { if (settings.isNsfwContentDisabled) {
removeAll { it.isNsfw } removeAll { it.isNsfw() }
} }
when (kind) { when (kind) {
SearchKind.TITLE -> retainAll { m -> SearchKind.TITLE -> retainAll { m ->

@ -229,7 +229,7 @@ class SuggestionsWorker @AssistedInject constructor(
if (details.rating > 0 && details.rating < RATING_MIN) { if (details.rating > 0 && details.rating < RATING_MIN) {
continue continue
} }
if (details.isNsfw && (appSettings.isSuggestionsExcludeNsfw || appSettings.isNsfwContentDisabled)) { if (details.isNsfw() && (appSettings.isSuggestionsExcludeNsfw || appSettings.isNsfwContentDisabled)) {
continue continue
} }
if (details in tagsBlacklist) { if (details in tagsBlacklist) {
@ -277,7 +277,7 @@ class SuggestionsWorker @AssistedInject constructor(
filter = MangaListFilter(tags = setOfNotNull(tag)), filter = MangaListFilter(tags = setOfNotNull(tag)),
).asArrayList() ).asArrayList()
if (appSettings.isSuggestionsExcludeNsfw) { if (appSettings.isSuggestionsExcludeNsfw) {
list.removeAll { it.isNsfw } list.removeAll { it.isNsfw() }
} }
if (blacklist.isNotEmpty()) { if (blacklist.isNotEmpty()) {
list.removeAll { manga -> manga in blacklist } list.removeAll { manga -> manga in blacklist }

@ -34,7 +34,7 @@ material = "1.14.0-alpha03"
moshi = "1.15.2" moshi = "1.15.2"
okhttp = "4.12.0" okhttp = "4.12.0"
okio = "3.12.0" okio = "3.12.0"
parsers = "6fb4cc608c" parsers = "fd0df2414e"
preference = "1.2.1" preference = "1.2.1"
recyclerview = "1.4.0" recyclerview = "1.4.0"
room = "2.7.2" room = "2.7.2"

Loading…
Cancel
Save