add tag_is_hashtag to remove some duplicate logic

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-08-19 07:30:12 -07:00
parent d7b5669ecf
commit 3b7f7706b5
3 changed files with 8 additions and 6 deletions

View File

@@ -79,9 +79,13 @@ func should_show_chatroom(_ ev: NostrEvent) -> Bool {
return has_hashtag(ev.tags, hashtag: "chat")
}
func tag_is_hashtag(_ tag: [String]) -> Bool {
return tag.count >= 2 && (tag[0] == "hashtag" || tag[0] == "t")
}
func has_hashtag(_ tags: [[String]], hashtag: String) -> Bool {
for tag in tags {
if tag.count >= 2 && (tag[0] == "hashtag" || tag[0] == "t") && tag[1] == hashtag {
if tag_is_hashtag(tag) && tag[1] == hashtag {
return true
}
}