diff --git a/damus/ContentView.swift b/damus/ContentView.swift index 7d1af32..d61be59 100644 --- a/damus/ContentView.swift +++ b/damus/ContentView.swift @@ -340,7 +340,7 @@ struct ContentView: View { } func is_friend_event(_ ev: NostrEvent) -> Bool { - return damus.is_friend_event(ev, our_pubkey: self.pubkey, contacts: self.damus_state!.contacts) + return damus.is_friend_event(ev, our_pubkey: self.pubkey, friends: self.damus_state!.contacts.friends) } func switch_timeline(_ timeline: Timeline) { @@ -775,28 +775,3 @@ func update_filters_with_since(last_of_kind: [Int: NostrEvent], filters: [NostrF } } - -func is_friend_event(_ ev: NostrEvent, our_pubkey: String, contacts: Contacts) -> Bool -{ - if ev.pubkey == our_pubkey { - return true - } - - if contacts.is_friend(ev.pubkey) { - return true - } - - if ev.is_reply { - // show our replies? - if ev.pubkey == our_pubkey { - return true - } - for pk in ev.referenced_pubkeys { - if contacts.is_friend(pk.ref_id) { - return true - } - } - } - - return false -} diff --git a/damus/Models/Contacts.swift b/damus/Models/Contacts.swift index 30663db..94c6bd9 100644 --- a/damus/Models/Contacts.swift +++ b/damus/Models/Contacts.swift @@ -120,3 +120,28 @@ func make_contact_relays(_ relays: [RelayDescriptor]) -> [String: RelayInfo] { } } + +func is_friend_event(_ ev: NostrEvent, our_pubkey: String, friends: Set) -> Bool +{ + if ev.pubkey == our_pubkey { + return true + } + + if friends.contains(ev.pubkey) { + return true + } + + if ev.is_reply { + // show our replies? + if ev.pubkey == our_pubkey { + return true + } + for pk in ev.referenced_pubkeys { + if friends.contains(pk.ref_id) { + return true + } + } + } + + return false +}