mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Minor cleanup
This commit is contained in:
parent
cce919750a
commit
b6a1e89535
2 changed files with 14 additions and 9 deletions
|
@ -26,6 +26,9 @@ import uy.kohesive.injekt.injectLazy
|
||||||
internal object ExtensionLoader {
|
internal object ExtensionLoader {
|
||||||
|
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
|
private val allowNsfwSource by lazy {
|
||||||
|
preferences.allowNsfwSource().get()
|
||||||
|
}
|
||||||
|
|
||||||
private const val EXTENSION_FEATURE = "tachiyomi.extension"
|
private const val EXTENSION_FEATURE = "tachiyomi.extension"
|
||||||
private const val METADATA_SOURCE_CLASS = "tachiyomi.extension.class"
|
private const val METADATA_SOURCE_CLASS = "tachiyomi.extension.class"
|
||||||
|
@ -129,7 +132,7 @@ internal object ExtensionLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
val isNsfw = appInfo.metaData.getInt(METADATA_NSFW) == 1
|
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")
|
return LoadResult.Error("NSFW extension $pkgName not allowed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +160,7 @@ internal object ExtensionLoader {
|
||||||
return LoadResult.Error(e)
|
return LoadResult.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.filter { preferences.allowNsfwSource().get() == PreferenceValues.NsfwAllowance.ALLOWED || !isSourceNsfw(it) }
|
.filter { allowNsfwSource == PreferenceValues.NsfwAllowance.ALLOWED || !isSourceNsfw(it) }
|
||||||
|
|
||||||
val langs = sources.filterIsInstance<CatalogueSource>()
|
val langs = sources.filterIsInstance<CatalogueSource>()
|
||||||
.map { it.lang }
|
.map { it.lang }
|
||||||
|
|
|
@ -182,13 +182,15 @@ open class GlobalSearchPresenter(
|
||||||
.map { result ->
|
.map { result ->
|
||||||
items
|
items
|
||||||
.map { item -> if (item.source == result.source) result else item }
|
.map { item -> if (item.source == result.source) result else item }
|
||||||
.sortedWith(compareBy(
|
.sortedWith(
|
||||||
|
compareBy(
|
||||||
// Bubble up sources that actually have results
|
// Bubble up sources that actually have results
|
||||||
{ it.results.isNullOrEmpty() },
|
{ it.results.isNullOrEmpty() },
|
||||||
// Same as initial sort, i.e. pinned first then alphabetically
|
// Same as initial sort, i.e. pinned first then alphabetically
|
||||||
{ it.source.id.toString() !in pinnedSourceIds },
|
{ it.source.id.toString() !in pinnedSourceIds },
|
||||||
{ "${it.source.name} (${it.source.lang})" }
|
{ "${it.source.name} (${it.source.lang})" }
|
||||||
))
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// Update current state
|
// Update current state
|
||||||
.doOnNext { items = it }
|
.doOnNext { items = it }
|
||||||
|
|
Loading…
Reference in a new issue