1: 55884f34 ! 1: 29351d48 fix: npub search fails on the first try @@ Metadata Author: Bryan Montz ## Commit message ## - fix: npub search fails on the first try + Fix npub search fails on the first try + Co-authored-by: William Casarin + Changelog-Fixed: Fix npub search fails on the first try Closes: #1044 - Changelog-Fixed: npub search fails on the first try + + ## damus/ContentView.swift ## +@@ damus/ContentView.swift: func find_event(state: DamusState, evid: String, search_type: SearchType, find_f + break + case .event(_, let ev): + has_event = true +- callback(ev) ++ + state.pool.unsubscribe(sub_id: subid) ++ ++ if search_type == .profile && ev.known_kind == .metadata { ++ process_metadata_event(events: state.events, our_pubkey: state.pubkey, profiles: state.profiles, ev: ev) { ++ callback(ev) ++ } ++ } else { ++ callback(ev) ++ } + case .eose: + if !has_event { + attempts += 1 ## damus/Models/HomeModel.swift ## @@ damus/Models/HomeModel.swift: func guard_valid_event(events: EventCache, ev: NostrEvent, callback: @escaping ( @@ damus/Views/Search/SearchingEventView.swift: struct SearchingEventView: View { } case .profile: - find_event(state: state, evid: evid, search_type: search_type, find_from: nil) { _ in -- if state.profiles.lookup(id: evid) != nil { -- self.search_state = .found_profile(evid) -- return + find_event(state: state, evid: evid, search_type: search_type, find_from: nil) { ev in -+ if let ev { -+ process_metadata_event(events: state.events, our_pubkey: state.pubkey, profiles: state.profiles, ev: ev) { -+ if state.profiles.lookup(id: evid) != nil { -+ self.search_state = .found_profile(evid) -+ } else { -+ self.search_state = .not_found -+ } -+ } + if state.profiles.lookup(id: evid) != nil { + self.search_state = .found_profile(evid) +- return } else { self.search_state = .not_found }