Browse Source

refactor handle_event in SearchHomeModel

post-button-style
William Casarin 2 years ago
parent
commit
ba03be5b91
  1. 10
      damus/Models/SearchHomeModel.swift

10
damus/Models/SearchHomeModel.swift

@ -41,10 +41,10 @@ class SearchHomeModel: ObservableObject {
} }
func handle_event(relay_id: String, conn_ev: NostrConnectionEvent) { func handle_event(relay_id: String, conn_ev: NostrConnectionEvent) {
switch conn_ev { guard case .nostr_event(let event) = conn_ev else {
case .ws_event: return
break }
case .nostr_event(let event):
switch event { switch event {
case .event(let sub_id, let ev): case .event(let sub_id, let ev):
guard sub_id == self.base_subid || sub_id == self.profiles_subid else { guard sub_id == self.base_subid || sub_id == self.profiles_subid else {
@ -55,6 +55,7 @@ class SearchHomeModel: ObservableObject {
return return
} }
seen_pubkey.insert(ev.pubkey) seen_pubkey.insert(ev.pubkey)
let _ = insert_uniq_sorted_event(events: &events, new_ev: ev) { let _ = insert_uniq_sorted_event(events: &events, new_ev: ev) {
$0.created_at > $1.created_at $0.created_at > $1.created_at
} }
@ -76,7 +77,6 @@ class SearchHomeModel: ObservableObject {
break break
} }
} }
}
} }
func find_profiles_to_fetch_pk(profiles: Profiles, event_pubkeys: [String]) -> [String] { func find_profiles_to_fetch_pk(profiles: Profiles, event_pubkeys: [String]) -> [String] {

Loading…
Cancel
Save