Displays hashtags that are not in the text at the bottom of each note

This commit is contained in:
Vitor Pamplona 2023-03-23 08:57:28 -04:00
parent dd9ea5f27e
commit 6626be8e1c
3 changed files with 21 additions and 1 deletions

View File

@ -47,7 +47,7 @@ open class Event(
if (aTagValue != null) ATag.parse(aTagValue, relay) else null
}
fun hashtags() = tags.filter { it.firstOrNull() == "t" }.mapNotNull { it.getOrNull(1) }
override fun hashtags() = tags.filter { it.firstOrNull() == "t" }.mapNotNull { it.getOrNull(1) }
override fun isTaggedUser(idHex: String) = tags.any { it.getOrNull(0) == "p" && it.getOrNull(1) == idHex }

View File

@ -28,4 +28,5 @@ interface EventInterface {
fun isTaggedHash(hashtag: String): Boolean
fun isTaggedHashes(hashtag: Set<String>): Boolean
fun firstIsTaggedHashes(hashtag: Set<String>): String?
fun hashtags(): List<String>
}

View File

@ -482,6 +482,25 @@ fun NoteCompose(
accountViewModel,
navController
)
val hashtags = noteEvent.hashtags()
if (hashtags.isNotEmpty()) {
FlowRow() {
hashtags.forEach {
if (!eventContent.contains(it, true)) {
ClickableText(
text = AnnotatedString("#$it "),
onClick = { navController.navigate("Hashtag/$it") },
style = LocalTextStyle.current.copy(
color = MaterialTheme.colors.primary.copy(
alpha = 0.52f
)
)
)
}
}
}
}
}
if (!makeItShort) {