From 9cfca5272e1710f3f5078a687feb450e8fda9eba Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 26 May 2026 21:44:50 +0000 Subject: [PATCH] fix(wallet): replace the chooser in the back stack when user picks a type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: after saving an NWC connection (or any conclusion of the form screen), nav.popBack() landed on the wallet-type chooser instead of the Wallet screen. The chooser would then sit there as a useless dead end requiring another back press to escape. Same bug existed on the Cashu add path from the chooser, though the edit-from-CashuWalletScreen path was unaffected because it bypassed the chooser entirely. Fix: at the chooser, replace the chooser entry with the form via popUpTo(target, Route.WalletAdd::class) instead of pushing the form on top via nav.nav(target). Now: * From + on Wallet → Choose → NWC → Save → back to Wallet (1 pop) * From + on Wallet → Choose → Cashu → Save → back to Wallet (1 pop) * From CashuWalletScreen → Edit → Save → back to CashuWallet (unchanged) * Back button from inside the form now also goes directly to Wallet, skipping the chooser that's no longer in the stack — a minor improvement since the chooser had nothing useful to return to after a type was picked. --- .../ui/screen/loggedIn/wallet/AddWalletScreen.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/AddWalletScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/AddWalletScreen.kt index 493ba871ae..b5a58153b0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/AddWalletScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/wallet/AddWalletScreen.kt @@ -92,13 +92,18 @@ fun AddWalletScreen( icon = MaterialSymbols.Bolt, title = stringRes(R.string.wallet_add_nwc_title), description = stringRes(R.string.wallet_add_nwc_description), - onClick = { nav.nav(Route.WalletAddNwc) }, + // Replace the chooser in the back stack rather than stacking + // the form on top: once the user picks a wallet type, the + // chooser has done its job. Without this, completing the + // add-wallet form pops back to the chooser, which is a + // pointless dead end. + onClick = { nav.popUpTo(Route.WalletAddNwc, Route.WalletAdd::class) }, ) WalletTypeCard( icon = MaterialSymbols.AccountBalanceWallet, title = stringRes(R.string.wallet_add_cashu_title), description = stringRes(R.string.wallet_add_cashu_description), - onClick = { nav.nav(Route.WalletAddCashu) }, + onClick = { nav.popUpTo(Route.WalletAddCashu, Route.WalletAdd::class) }, ) } }