From f698b31eee88655f532b99e1add55f0ab8e90d0b Mon Sep 17 00:00:00 2001 From: nrobi144 Date: Thu, 30 Apr 2026 10:12:40 +0300 Subject: [PATCH] fix(multi-account): account removal now switches or logs out properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../amethyst/desktop/account/AccountManager.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManager.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManager.kt index 497cd051b..3b6b113cf 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManager.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/account/AccountManager.kt @@ -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) } } }