Adds hidden words filter to search, hashtag and geotag feeds

Applies hidden words even to hashtags that were not included in the content of the event.
Pre-process search to avoid showing and hiding posts after hidden words where processed by the UI.
This commit is contained in:
Vitor Pamplona
2024-10-24 11:00:07 -04:00
parent f88985b2bf
commit 518e1c88ce
11 changed files with 92 additions and 37 deletions

View File

@@ -107,6 +107,19 @@ open class Event(
}
}
override fun anyHashTag(onEach: (str: String) -> Boolean) = anyTagged("t", onEach)
private fun anyTagged(
tagName: String,
onEach: (str: String) -> Boolean,
) = tags.any {
if (it.size > 1 && it[0] == tagName) {
onEach(it[1])
} else {
false
}
}
override fun <R> mapTaggedEvent(map: (eventId: HexKey) -> R) = mapTagged("e", map)
override fun <R> mapTaggedAddress(map: (address: String) -> R) = mapTagged("a", map)

View File

@@ -121,6 +121,8 @@ interface EventInterface {
fun forEachHashTag(onEach: (eventId: HexKey) -> Unit)
fun anyHashTag(onEach: (str: String) -> Boolean): Boolean
fun <R> mapTaggedEvent(map: (eventId: HexKey) -> R): List<R>
fun <R> mapTaggedAddress(map: (address: String) -> R): List<R>