Revert "Revert "nostrdb: close database when backgrounded""
This reverts commit 26bd50c948.
This commit is contained in:
@@ -461,18 +461,25 @@ struct ContentView: View {
|
||||
.onReceive(handle_notify(.disconnect_relays)) { () in
|
||||
damus_state.pool.disconnect()
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { obj in
|
||||
print("📙 DAMUS ACTIVE NOTIFY")
|
||||
try? damus_state.ndb.reopen()
|
||||
}
|
||||
.onChange(of: scenePhase) { (phase: ScenePhase) in
|
||||
guard let damus_state else { return }
|
||||
switch phase {
|
||||
case .background:
|
||||
print("📙 DAMUS BACKGROUNDED")
|
||||
Task { @MainActor in
|
||||
damus_state.ndb.close()
|
||||
}
|
||||
break
|
||||
case .inactive:
|
||||
print("📙 DAMUS INACTIVE")
|
||||
break
|
||||
case .active:
|
||||
print("📙 DAMUS ACTIVE")
|
||||
guard let ds = damus_state else { return }
|
||||
ds.pool.ping()
|
||||
damus_state.pool.ping()
|
||||
@unknown default:
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user