feat: wipe database on logout #25

Merged
reya merged 2 commits from feat/prune-on-logout into master 2026-06-25 08:12:28 +00:00
2 changed files with 14 additions and 3 deletions
Showing only changes of commit 6d69e15d7e - Show all commits

View File

@@ -188,6 +188,14 @@ class Nostr {
} }
} }
suspend fun prune() {
try {
client?.database()?.wipe()
} catch (e: Exception) {
throw IllegalStateException("Failed to prune database: ${e.message}", e)
}
}
suspend fun setSigner(new: AsyncNostrSigner) { suspend fun setSigner(new: AsyncNostrSigner) {
try { try {
signer.switch(new) signer.switch(new)

View File

@@ -325,8 +325,11 @@ class NostrViewModel(
fun logout() { fun logout() {
viewModelScope.launch { viewModelScope.launch {
secretStore.clear("user_signer") // Reset the nostr state and wipe database
nostr.signer.switch(Keys.generate()) nostr.signer.switch(Keys.generate())
nostr.prune()
// Clear credential
secretStore.clear("user_signer")
_signerRequired.value = true _signerRequired.value = true
} }
} }