Add tags blacklist option for suggestions
This commit is contained in:
@@ -76,7 +76,10 @@ class SuggestionsWorker(appContext: Context, params: WorkerParameters) :
|
||||
suggestionRepository.clear()
|
||||
return 0
|
||||
}
|
||||
val allTags = historyRepository.getPopularTags(TAGS_LIMIT)
|
||||
val blacklistTagRegex = appSettings.getSuggestionsTagsBlacklistRegex()
|
||||
val allTags = historyRepository.getPopularTags(TAGS_LIMIT).filterNot {
|
||||
blacklistTagRegex?.containsMatchIn(it.title) ?: false
|
||||
}
|
||||
if (allTags.isEmpty()) {
|
||||
return 0
|
||||
}
|
||||
@@ -102,6 +105,11 @@ class SuggestionsWorker(appContext: Context, params: WorkerParameters) :
|
||||
if (appSettings.isSuggestionsExcludeNsfw) {
|
||||
rawResults.removeAll { it.isNsfw }
|
||||
}
|
||||
if (blacklistTagRegex != null) {
|
||||
rawResults.removeAll {
|
||||
it.tags.any { x -> blacklistTagRegex.containsMatchIn(x.title) }
|
||||
}
|
||||
}
|
||||
if (rawResults.isEmpty()) {
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user