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 26 additions and 7 deletions
Showing only changes of commit ce2b573e63 - Show all commits

View File

@@ -781,7 +781,7 @@ fun BottomMenuList(
}
Spacer(modifier = Modifier.size(16.dp))
FilledTonalButton(
onClick = { viewModel.logout() },
onClick = { onDismiss { viewModel.logout() } },
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = MaterialTheme.colorScheme.error,
contentColor = MaterialTheme.colorScheme.onError

View File

@@ -325,14 +325,33 @@ class NostrViewModel(
fun logout() {
viewModelScope.launch {
// Reset the nostr state and wipe database
try {
_isBusy.value = true
// Reset the nostr signer and prune the database
nostr.signer.switch(Keys.generate())
nostr.prune()
// Clear credential
} catch (e: Exception) {
showError("Logout encountered an error: ${e.message}")
} finally {
// Clear credentials from persistent storage
secretStore.clear("user_signer")
// Reset all UI states
resetInternalState()
_isBusy.value = false
_signerRequired.value = true
}
}
}
private fun resetInternalState() {
_chatRooms.value = emptySet()
_contactList.value = emptySet()
_isPartialProcessedGiftWrap.value = false
_isRelayListEmpty.value = false
_isNotificationBannerDismissed.value = false
}
fun dismissNotificationBanner() {
viewModelScope.launch {