damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 9c6b802f19f0349c222084eae722101487373220
parent 4c7b8dc10b1739593b45aa417a46af969c6ff59f
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  2 Jan 2023 07:54:53 -0800

Fix follows and relays getting out of sync on profile pages

Fixes: #216
Changelog-Fixed: Fixed follows and relays getting out of sync on profile pages

Diffstat:
Mdamus/Models/ProfileModel.swift | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/damus/Models/ProfileModel.swift b/damus/Models/ProfileModel.swift @@ -61,7 +61,7 @@ class ProfileModel: ObservableObject, Equatable { profile_filter.authors = [pubkey] text_filter.authors = [pubkey] - text_filter.limit = 1000 + text_filter.limit = 500 print("subscribing to profile \(pubkey) with sub_id \(sub_id)") print_filters(relay_id: "profile", filters: [[text_filter], [profile_filter]]) @@ -70,12 +70,18 @@ class ProfileModel: ObservableObject, Equatable { } func handle_profile_contact_event(_ ev: NostrEvent) { + process_contact_event(pool: damus.pool, contacts: damus.contacts, pubkey: damus.pubkey, ev: ev) + + // only use new stuff + if let current_ev = self.contacts { + guard ev.created_at > current_ev.created_at else { + return + } + } + self.contacts = ev self.following = count_pubkeys(ev.tags) self.relays = decode_json_relays(ev.content) - if damus.contacts.is_friend(ev.pubkey) { - self.damus.contacts.add_friend_contact(ev) - } } func add_event(_ ev: NostrEvent) { @@ -90,6 +96,8 @@ class ProfileModel: ObservableObject, Equatable { let _ = insert_uniq_sorted_event(events: &self.events, new_ev: ev, cmp: { $0.created_at > $1.created_at}) } else if ev.known_kind == .contacts { handle_profile_contact_event(ev) + } else if ev.known_kind == .metadata { + process_metadata_event(profiles: damus.profiles, ev: ev) } seen_event.insert(ev.id) }