fix(multi-account): account removal now switches or logs out properly

removeAccountFromStorage was calling loadSavedAccount() which reads
from legacy last_account.txt — didn't trigger feed/relay reload.

Now calls switchAccount(nextNpub) for proper relay reconnection and
feed reload, or logout(deleteKey=true) if no accounts remain.

Also cleans up bunker ephemeral keys on removal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
nrobi144
2026-04-30 10:12:40 +03:00
parent ec3a4adb46
commit f698b31eee
@@ -704,16 +704,20 @@ class AccountManager internal constructor(
secureStorage.deletePrivateKey(npub)
} catch (_: SecureStorageException) {
}
try {
secureStorage.deletePrivateKey(bunkerEphemeralKeyAlias(npub))
} catch (_: SecureStorageException) {
}
refreshAccountList()
// If we removed the active account, load the next one or log out
// If we removed the active account, switch to next or log out
if (current?.npub == npub) {
val next = accountStorage.currentAccount()
if (next != null) {
loadSavedAccount()
val nextNpub = accountStorage.currentAccount()
if (nextNpub != null) {
switchAccount(nextNpub)
} else {
logout(deleteKey = false)
logout(deleteKey = true)
}
}
}