From 9a714943fdae28538f2e9824c7ee97ca2b6dd7fb Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 13 Jul 2023 11:02:13 -0700 Subject: [PATCH] contacts: get followed hashtags function todo: cache these --- damus/Models/Contacts.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/damus/Models/Contacts.swift b/damus/Models/Contacts.swift index cce25c4b..f64c7e01 100644 --- a/damus/Models/Contacts.swift +++ b/damus/Models/Contacts.swift @@ -69,7 +69,16 @@ class Contacts { func get_friend_list() -> [String] { return Array(friends) } - + + func get_followed_hashtags() -> Set { + guard let ev = self.event else { return Set() } + return ev.tags.reduce(into: Set(), { htags, tag in + if tag.count >= 2 && tag[0] == "t" && tag[1] != "" { + htags.insert(tag[1]) + } + }) + } + func add_friend_pubkey(_ pubkey: String) { friends.insert(pubkey) }