Skip nsfw sources for recommendations if disabled

This commit is contained in:
Koitharu
2024-08-20 16:28:39 +03:00
parent 0f28d5de11
commit 6e8a1cd6af

View File

@@ -48,6 +48,7 @@ import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.browser.cloudflare.CaptchaNotifier
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
import org.koitharu.kotatsu.core.model.distinctById
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.ext.almostEquals
@@ -187,6 +188,9 @@ class SuggestionsWorker @AssistedInject constructor(
val semaphore = Semaphore(MAX_PARALLELISM)
val producer = channelFlow {
for (it in sources.shuffled()) {
if (it.isNsfw() && appSettings.isSuggestionsExcludeNsfw) {
continue
}
launch {
semaphore.withPermit {
send(getList(it, tags, tagsBlacklist))