Ping relays on resume, if there's an error then try to reconnect

This is an attempt to fix the fail-to-reconnect issues. Let's see if it works.
This commit is contained in:
William Casarin
2023-05-07 10:28:36 -07:00
parent f78eeb1f22
commit 84174ef9ad
4 changed files with 49 additions and 4 deletions

View File

@@ -59,6 +59,8 @@ struct ContentView: View {
return keypair.privkey
}
@Environment(\.scenePhase) var scenePhase
@State var status: String = "Not connected"
@State var active_sheet: Sheets? = nil
@State var damus_state: DamusState? = nil
@@ -403,6 +405,22 @@ struct ContentView: View {
.onReceive(handle_notify(.unmute_thread)) { notif in
home.filter_events()
}
.onChange(of: scenePhase) { (phase: ScenePhase) in
switch phase {
case .background:
print("📙 DAMUS BACKGROUNDED")
break
case .inactive:
print("📙 DAMUS INACTIVE")
break
case .active:
print("📙 DAMUS ACTIVE")
guard let ds = damus_state else { return }
ds.pool.ping()
@unknown default:
break
}
}
.onReceive(handle_notify(.local_notification)) { notif in
guard let local = notif.object as? LossyLocalNotification,