support kind 42 chat messages

Changelog-Added: Support kind 42 chat messages (ArcadeCity).
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-08-19 07:21:18 -07:00
parent 8141a2970c
commit d7b5669ecf
9 changed files with 36 additions and 7 deletions

View File

@@ -51,7 +51,7 @@ struct ThreadView: View {
return
}
seen_first = true
is_chatroom = has_hashtag(ev.tags, hashtag: "chat")
is_chatroom = should_show_chatroom(ev)
}
}
.onAppear() {
@@ -71,9 +71,17 @@ struct ThreadView_Previews: PreviewProvider {
}
*/
func should_show_chatroom(_ ev: NostrEvent) -> Bool {
if ev.known_kind == .chat {
return true
}
return has_hashtag(ev.tags, hashtag: "chat")
}
func has_hashtag(_ tags: [[String]], hashtag: String) -> Bool {
for tag in tags {
if tag.count >= 2 && tag[0] == "hashtag" && tag[1] == hashtag {
if tag.count >= 2 && (tag[0] == "hashtag" || tag[0] == "t") && tag[1] == hashtag {
return true
}
}