damus

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

commit 87a0bdac9494ce4f9987100dd807b07c6a3224e5
parent 37b964c296a442dbe46c72ef02296090a8cf046a
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 21 Feb 2023 10:08:15 -0800

Load missing profiles in Zaps view

Changelog-Fixed: Load missing profiles in Zaps view

Diffstat:
Mdamus/Models/ZapsModel.swift | 50++++++++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/damus/Models/ZapsModel.swift b/damus/Models/ZapsModel.swift @@ -13,6 +13,7 @@ class ZapsModel: ObservableObject { var zaps: [Zap] let zaps_subid = UUID().description + let profiles_subid = UUID().description init(state: DamusState, target: ZapTarget) { self.state = state @@ -44,34 +45,39 @@ class ZapsModel: ObservableObject { return } - guard case .event(_, let ev) = resp else { - return - } - - guard ev.kind == 9735 else { - return - } - - if let zap = state.zaps.zaps[ev.id] { - if insert_uniq_sorted_zap(zaps: &zaps, new_zap: zap) { - objectWillChange.send() - } - } else { - guard let zapper = state.profiles.lookup_zapper(pubkey: target.pubkey) else { - return - } - - guard let zap = Zap.from_zap_event(zap_ev: ev, zapper: zapper) else { + switch resp { + case .notice: + break + case .eose: + let events = self.zaps.map { $0.request.ev } + load_profiles(profiles_subid: profiles_subid, relay_id: relay_id, events: events, damus_state: state) + case .event(_, let ev): + guard ev.kind == 9735 else { return } - state.zaps.add_zap(zap: zap) - - if insert_uniq_sorted_zap(zaps: &zaps, new_zap: zap) { - objectWillChange.send() + if let zap = state.zaps.zaps[ev.id] { + if insert_uniq_sorted_zap(zaps: &zaps, new_zap: zap) { + objectWillChange.send() + } + } else { + guard let zapper = state.profiles.lookup_zapper(pubkey: target.pubkey) else { + return + } + + guard let zap = Zap.from_zap_event(zap_ev: ev, zapper: zapper) else { + return + } + + state.zaps.add_zap(zap: zap) + + if insert_uniq_sorted_zap(zaps: &zaps, new_zap: zap) { + objectWillChange.send() + } } } + } }