close nostrdb and disconnect from relays on logout
This was causing crashing and corruption issues. This should have been handled by the garbage collector, but for some reason old references still hang around. Add a "close" method to DamusState which disconnects from relays and closes nostrdb. Changelog-Fixed: Fix crash when logging out and switching accounts Changelog-Fixed: Fix persistent local notifications even after logout Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -39,6 +39,16 @@ class RelayPool {
|
||||
private let network_monitor_queue = DispatchQueue(label: "io.damus.network_monitor")
|
||||
private var last_network_status: NWPath.Status = .unsatisfied
|
||||
|
||||
func close() {
|
||||
disconnect()
|
||||
relays = []
|
||||
handlers = []
|
||||
request_queue = []
|
||||
seen.removeAll()
|
||||
counts = [:]
|
||||
keypair = nil
|
||||
}
|
||||
|
||||
init(ndb: Ndb, keypair: Keypair? = nil) {
|
||||
self.ndb = ndb
|
||||
self.keypair = keypair
|
||||
|
||||
Reference in New Issue
Block a user