From 62c4ee22a405dfec3aac572b9519023f4c4e1bf3 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Wed, 28 Apr 2021 14:48:48 -0400 Subject: [PATCH] Fix NSFW sources showing in extensions list while setting is off --- .../tachiyomi/ui/extension/ExtensionBottomPresenter.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt index 68d9ffe0c9..ea4f60f383 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/extension/ExtensionBottomPresenter.kt @@ -146,19 +146,22 @@ class ExtensionBottomPresenter( private fun toItems(tuple: ExtensionTuple): List { val context = bottomSheet.context val activeLangs = preferences.enabledLanguages().get() + val showNsfwExtensions = preferences.showNsfwExtension().get() val (installed, untrusted, available) = tuple val items = mutableListOf() - val installedSorted = installed.sortedWith(compareBy({ !it.hasUpdate }, { !it.isObsolete }, { it.pkgName })) + val installedSorted = installed.filter { showNsfwExtensions || !it.isNsfw } + .sortedWith(compareBy({ !it.hasUpdate }, { !it.isObsolete }, { it.pkgName })) val untrustedSorted = untrusted.sortedBy { it.pkgName } val availableSorted = available // Filter out already installed extensions and disabled languages .filter { avail -> installed.none { it.pkgName == avail.pkgName } && untrusted.none { it.pkgName == avail.pkgName } && - (avail.lang in activeLangs || avail.lang == "all") + (avail.lang in activeLangs || avail.lang == "all") && + (showNsfwExtensions || !avail.isNsfw) } .sortedBy { it.pkgName }