commit ba03be5b91f0b8725411ee2d7c167028ab359384
parent 3f3b78f9bc5aca3807c9420fe593a91b53c86bed
Author: William Casarin <jb55@jb55.com>
Date: Mon, 2 Jan 2023 18:56:10 -0800
refactor handle_event in SearchHomeModel
Diffstat:
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/damus/Models/SearchHomeModel.swift b/damus/Models/SearchHomeModel.swift
@@ -41,40 +41,40 @@ class SearchHomeModel: ObservableObject {
}
func handle_event(relay_id: String, conn_ev: NostrConnectionEvent) {
- switch conn_ev {
- case .ws_event:
- break
- case .nostr_event(let event):
- switch event {
- case .event(let sub_id, let ev):
- guard sub_id == self.base_subid || sub_id == self.profiles_subid else {
+ guard case .nostr_event(let event) = conn_ev else {
+ return
+ }
+
+ switch event {
+ case .event(let sub_id, let ev):
+ guard sub_id == self.base_subid || sub_id == self.profiles_subid else {
+ return
+ }
+ if ev.is_textlike && ev.should_show_event {
+ if seen_pubkey.contains(ev.pubkey) {
return
}
- if ev.is_textlike && ev.should_show_event {
- if seen_pubkey.contains(ev.pubkey) {
- return
- }
- seen_pubkey.insert(ev.pubkey)
- let _ = insert_uniq_sorted_event(events: &events, new_ev: ev) {
- $0.created_at > $1.created_at
- }
- }
- case .notice(let msg):
- print("search home notice: \(msg)")
- case .eose(let sub_id):
- loading = false
+ seen_pubkey.insert(ev.pubkey)
- if sub_id == self.base_subid {
- // Make sure we unsubscribe after we've fetched the global events
- // global events are not realtime
- unsubscribe(to: relay_id)
-
- load_profiles(profiles_subid: profiles_subid, relay_id: relay_id, events: events, damus_state: damus_state)
+ let _ = insert_uniq_sorted_event(events: &events, new_ev: ev) {
+ $0.created_at > $1.created_at
}
+ }
+ case .notice(let msg):
+ print("search home notice: \(msg)")
+ case .eose(let sub_id):
+ loading = false
+
+ if sub_id == self.base_subid {
+ // Make sure we unsubscribe after we've fetched the global events
+ // global events are not realtime
+ unsubscribe(to: relay_id)
-
- break
+ load_profiles(profiles_subid: profiles_subid, relay_id: relay_id, events: events, damus_state: damus_state)
}
+
+
+ break
}
}
}