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

@@ -92,7 +92,12 @@ struct DamusState: HeadlessDamusState {
var is_privkey_user: Bool {
keypair.privkey != nil
}
func close() {
pool.close()
ndb.close()
}
static var empty: DamusState {
let empty_pub: Pubkey = .empty
let empty_sec: Privkey = .empty