Fix npub search fails on the first try

Co-authored-by: William Casarin <jb55@jb55.com>
Changelog-Fixed: Fix npub search fails on the first try
Closes: #1044
Closes: #1100
This commit is contained in:
Bryan Montz
2023-05-05 21:57:47 -05:00
committed by William Casarin
parent a007e18add
commit f78eeb1f22
3 changed files with 13 additions and 4 deletions

View File

@@ -761,10 +761,11 @@ func guard_valid_event(events: EventCache, ev: NostrEvent, callback: @escaping (
}
}
func process_metadata_event(events: EventCache, our_pubkey: String, profiles: Profiles, ev: NostrEvent) {
func process_metadata_event(events: EventCache, our_pubkey: String, profiles: Profiles, ev: NostrEvent, completion: (() -> Void)? = nil) {
guard_valid_event(events: events, ev: ev) {
DispatchQueue.global(qos: .background).async {
guard let profile: Profile = decode_data(Data(ev.content.utf8)) else {
completion?()
return
}
@@ -772,6 +773,7 @@ func process_metadata_event(events: EventCache, our_pubkey: String, profiles: Pr
DispatchQueue.main.async {
process_metadata_profile(our_pubkey: our_pubkey, profiles: profiles, profile: profile, ev: ev)
completion?()
}
}
}