diff --git a/damus/Models/SearchModel.swift b/damus/Models/SearchModel.swift index 14fccb3..4b4d483 100644 --- a/damus/Models/SearchModel.swift +++ b/damus/Models/SearchModel.swift @@ -65,10 +65,8 @@ class SearchModel: ObservableObject { func event_matches_hashtag(_ ev: NostrEvent, hashtags: [String]) -> Bool { for tag in ev.tags { - if tag.count >= 2 && tag[0] == "hashtag" { - if hashtags.contains(tag[1]) { - return true - } + if tag_is_hashtag(tag) && hashtags.contains(tag[1]) { + return true } } return false diff --git a/damus/Nostr/NostrLink.swift b/damus/Nostr/NostrLink.swift index c800890..ca6ff31 100644 --- a/damus/Nostr/NostrLink.swift +++ b/damus/Nostr/NostrLink.swift @@ -93,7 +93,7 @@ func decode_nostr_uri(_ s: String) -> NostrLink? { return } - if parts.count >= 2 && parts[0] == "hashtag" { + if tag_is_hashtag(parts) { return .filter(NostrFilter.filter_hashtag([parts[1].lowercased()])) } diff --git a/damus/Views/ThreadView.swift b/damus/Views/ThreadView.swift index dcc0322..de867b1 100644 --- a/damus/Views/ThreadView.swift +++ b/damus/Views/ThreadView.swift @@ -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 } }