ProfileModel: add follows helper
This will be used for "Follows You" logic
This commit is contained in:
@@ -20,6 +20,24 @@ class ProfileModel: ObservableObject, Equatable {
|
|||||||
var sub_id = UUID().description
|
var sub_id = UUID().description
|
||||||
var prof_subid = 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 {
|
func get_follow_target() -> FollowTarget {
|
||||||
if let contacts = contacts {
|
if let contacts = contacts {
|
||||||
return .contact(contacts)
|
return .contact(contacts)
|
||||||
|
|||||||
Reference in New Issue
Block a user