mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-29 11:11:44 +01:00
Fixes thread rendering when "mention" events are added with mentioning the event.
This commit is contained in:
parent
5109b65e37
commit
bbc4ec2625
@ -42,13 +42,26 @@ open class BaseTextNoteEvent(
|
||||
) : Event(id, pubKey, createdAt, kind, tags, content, sig) {
|
||||
fun mentions() = taggedUsers()
|
||||
|
||||
open fun replyTos() = taggedEvents()
|
||||
open fun replyTos(): List<HexKey> {
|
||||
val oldStylePositional = tags.filter { it.size > 1 && it[0] == "e" }.map { it[1] }
|
||||
val newStyleReply = tags.lastOrNull { it.size > 3 && it[0] == "e" && it[3] == "reply" }?.get(1)
|
||||
val newStyleRoot = tags.lastOrNull { it.size > 3 && it[0] == "e" && it[3] == "root" }?.get(1)
|
||||
|
||||
val newStyleReplyTos = listOfNotNull(newStyleReply, newStyleRoot)
|
||||
|
||||
return if (newStyleReplyTos.isNotEmpty()) {
|
||||
newStyleReplyTos
|
||||
} else {
|
||||
oldStylePositional
|
||||
}
|
||||
}
|
||||
|
||||
fun replyingTo(): HexKey? {
|
||||
val oldStylePositional = tags.lastOrNull { it.size > 1 && it[0] == "e" }?.get(1)
|
||||
val newStyle = tags.lastOrNull { it.size > 3 && it[0] == "e" && it[3] == "reply" }?.get(1)
|
||||
val newStyleReply = tags.lastOrNull { it.size > 3 && it[0] == "e" && it[3] == "reply" }?.get(1)
|
||||
val newStyleRoot = tags.lastOrNull { it.size > 3 && it[0] == "e" && it[3] == "root" }?.get(1)
|
||||
|
||||
return newStyle ?: oldStylePositional
|
||||
return newStyleReply ?: newStyleRoot ?: oldStylePositional
|
||||
}
|
||||
|
||||
@Transient private var citedUsersCache: Set<HexKey>? = null
|
||||
|
Loading…
x
Reference in New Issue
Block a user