Browse Source

attempt reconnects every 4 seconds instead of 60

Changelog-Fixed: Damus will now stay connected at all times
Signed-off-by: William Casarin <jb55@jb55.com>
profile-edit
William Casarin 2 years ago
parent
commit
054714794d
  1. 3
      damus/ContentView.swift
  2. 12
      damus/Models/HomeModel.swift

3
damus/ContentView.swift

@ -68,7 +68,7 @@ struct ContentView: View {
@StateObject var home: HomeModel = HomeModel()
// connect retry timer
let timer = Timer.publish(every: 60, on: .main, in: .common).autoconnect()
let timer = Timer.publish(every: 4, on: .main, in: .common).autoconnect()
let sub_id = UUID().description
@ -329,6 +329,7 @@ struct ContentView: View {
}
.onReceive(timer) { n in
self.damus_state?.pool.connect_to_disconnected()
update_signal_from_pool(signal: self.home.signal, pool: self.damus_state!.pool)
}
}

12
damus/Models/HomeModel.swift

@ -190,15 +190,6 @@ class HomeModel: ObservableObject {
func handle_event(relay_id: String, conn_event: NostrConnectionEvent) {
switch conn_event {
case .ws_event(let ev):
/*
if let wsev = ws_nostr_event(relay: relay_id, ev: ev) {
wsev.flags |= 1
self.events.insert(wsev, at: 0)
}
*/
switch ev {
case .connected:
if !done_init {
@ -224,8 +215,6 @@ class HomeModel: ObservableObject {
break
}
update_signal_from_pool(signal: self.signal, pool: self.pool)
print("ws_event \(ev)")
case .nostr_event(let ev):
@ -603,3 +592,4 @@ func remove_bootstrap_nodes(_ damus_state: DamusState) {
}
}
}

Loading…
Cancel
Save