|
|
@ -84,22 +84,12 @@ struct BuildThreadV2View: View { |
|
|
|
return sub_id |
|
|
|
} |
|
|
|
|
|
|
|
func handle_event(relay_id: String, ev: NostrConnectionEvent) { |
|
|
|
guard case .nostr_event(let nostr_response) = ev else { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
guard case .event(let id, let nostr_event) = nostr_response else { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// Is current event |
|
|
|
if id == current_events_uuid { |
|
|
|
func handle_current_events(ev: NostrEvent) { |
|
|
|
if current_event != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
current_event = nostr_event |
|
|
|
current_event = ev |
|
|
|
|
|
|
|
thread = ThreadV2( |
|
|
|
parentEvents: [], |
|
|
@ -136,11 +126,10 @@ struct BuildThreadV2View: View { |
|
|
|
) |
|
|
|
childs_events_uuid = subscribe(filters: [childs_events]) |
|
|
|
print("ThreadV2View: Ask for children (\(childs_events) (\(childs_events_uuid))") |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if parents_events_uuids.contains(id) { |
|
|
|
func handle_parent_events(sub_id: String, nostr_event: NostrEvent) { |
|
|
|
|
|
|
|
// We are filtering this later |
|
|
|
thread!.parentEvents.append(nostr_event) |
|
|
|
|
|
|
@ -170,7 +159,28 @@ struct BuildThreadV2View: View { |
|
|
|
} |
|
|
|
|
|
|
|
thread!.clean() |
|
|
|
unsubscribe(id) |
|
|
|
unsubscribe(sub_id) |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func handle_event(relay_id: String, ev: NostrConnectionEvent) { |
|
|
|
guard case .nostr_event(let nostr_response) = ev else { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
guard case .event(let id, let nostr_event) = nostr_response else { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// Is current event |
|
|
|
if id == current_events_uuid { |
|
|
|
handle_current_events(ev: nostr_event) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if parents_events_uuids.contains(id) { |
|
|
|
handle_parent_events(sub_id: id, nostr_event: nostr_event) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|