fix: let Save commit a typed-but-unadded Cashu mint

When adding a Cashu wallet, the mint URL typed into the input field was
only committed to the mint list when the user pressed the "+" button. The
Save button was gated on the list being non-empty, so a user who typed a
mint, chose a key option, and tried to Save found the button disabled with
no obvious reason — they had to discover the "+" button first.

Save now folds a pending mint from the input field into the list, making
"+" optional. The button also enables when the input is non-blank.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VX5wkwXbvoQpadALx1ZVjk
This commit is contained in:
Claude
2026-06-25 23:00:06 +00:00
parent 82e1b99036
commit 6b3e216ea3
@@ -426,16 +426,28 @@ fun AddCashuWalletScreen(
Spacer(modifier = Modifier.height(24.dp))
// A mint typed into the input but not yet committed with the "+"
// button. Folding it into the save makes "+" optional: the user can
// type a mint and hit Save directly instead of being blocked by a
// disabled button with no obvious reason.
val pendingMint = mintInput.trim().trimEnd('/')
Button(
onClick = {
val allMints =
if (pendingMint.isNotEmpty() && pendingMint !in mints) {
mints.toList() + pendingMint
} else {
mints.toList()
}
viewModel.saveWallet(
mints = mints.toList(),
mints = allMints,
keyMode = keyMode,
manualPrivkey = manualPrivkey.takeIf { keyMode == CashuWalletViewModel.P2pkKeyMode.Manual },
)
},
enabled =
mints.isNotEmpty() &&
(mints.isNotEmpty() || pendingMint.isNotEmpty()) &&
createState !is CashuWalletCreateState.Saving &&
(keyMode != CashuWalletViewModel.P2pkKeyMode.Manual || manualPrivkey.isNotBlank()),
modifier = Modifier.fillMaxWidth(),