add tag_is_hashtag to remove some duplicate logic
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()]))
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user