ProfileModel: add follows helper

This will be used for "Follows You" logic
This commit is contained in:
William Casarin
2023-02-07 10:20:12 -08:00
parent 90cd48ead7
commit fb82cc0531

View File

@@ -20,6 +20,24 @@ class ProfileModel: ObservableObject, Equatable {
var sub_id = UUID().description
var prof_subid = UUID().description
func follows(pubkey: String) -> Bool {
guard let contacts = self.contacts else {
return false
}
for tag in contacts.tags {
guard tag.count >= 2 && tag[0] == "p" else {
continue
}
if tag[1] == pubkey {
return true
}
}
return false
}
func get_follow_target() -> FollowTarget {
if let contacts = contacts {
return .contact(contacts)