From b6a1e8953557320215f5328d393de38d43ed70d4 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 9 Aug 2020 12:05:04 -0400 Subject: [PATCH] Minor cleanup --- .../tachiyomi/extension/util/ExtensionLoader.kt | 7 +++++-- .../source/globalsearch/GlobalSearchPresenter.kt | 16 +++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt index fbbb71585..d7cdec526 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt @@ -26,6 +26,9 @@ import uy.kohesive.injekt.injectLazy internal object ExtensionLoader { private val preferences: PreferencesHelper by injectLazy() + private val allowNsfwSource by lazy { + preferences.allowNsfwSource().get() + } private const val EXTENSION_FEATURE = "tachiyomi.extension" private const val METADATA_SOURCE_CLASS = "tachiyomi.extension.class" @@ -129,7 +132,7 @@ internal object ExtensionLoader { } val isNsfw = appInfo.metaData.getInt(METADATA_NSFW) == 1 - if (preferences.allowNsfwSource().get() == PreferenceValues.NsfwAllowance.BLOCKED && isNsfw) { + if (allowNsfwSource == PreferenceValues.NsfwAllowance.BLOCKED && isNsfw) { return LoadResult.Error("NSFW extension $pkgName not allowed") } @@ -157,7 +160,7 @@ internal object ExtensionLoader { return LoadResult.Error(e) } } - .filter { preferences.allowNsfwSource().get() == PreferenceValues.NsfwAllowance.ALLOWED || !isSourceNsfw(it) } + .filter { allowNsfwSource == PreferenceValues.NsfwAllowance.ALLOWED || !isSourceNsfw(it) } val langs = sources.filterIsInstance() .map { it.lang } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt index 4807e28a7..bedf58add 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchPresenter.kt @@ -182,13 +182,15 @@ open class GlobalSearchPresenter( .map { result -> items .map { item -> if (item.source == result.source) result else item } - .sortedWith(compareBy( - // Bubble up sources that actually have results - { it.results.isNullOrEmpty() }, - // Same as initial sort, i.e. pinned first then alphabetically - { it.source.id.toString() !in pinnedSourceIds }, - { "${it.source.name} (${it.source.lang})" } - )) + .sortedWith( + compareBy( + // Bubble up sources that actually have results + { it.results.isNullOrEmpty() }, + // Same as initial sort, i.e. pinned first then alphabetically + { it.source.id.toString() !in pinnedSourceIds }, + { "${it.source.name} (${it.source.lang})" } + ) + ) } // Update current state .doOnNext { items = it }