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:
William Casarin
2024-01-10 16:25:07 -08:00
parent 6834367386
commit 4cf92756f1
6 changed files with 30 additions and 7 deletions

View File

@@ -176,6 +176,7 @@ class Ndb {
}
func close() {
guard !self.closed else { return }
self.closed = true
ndb_destroy(self.ndb.ndb)
}