From e3fd1c53e4f4c816b5b91d5dfcaa7abbf3da804a Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 5 Jul 2026 20:25:51 +0000 Subject: [PATCH] feat: hide on-chain wallet from zap buttons too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend the showOnchainWallet preference to the zap flows, which also surface an on-chain rail: - the on-chain rail on each zap-amount chip in ZapAmountChoicePopup (folded into the shared railCapability so every caller — reaction row, ReusableZapButton — is covered) - the "Send on-chain instead" hand-off button in the custom zap dialog Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01UM57Rq5iUPL1SGhzhzTusa --- .../amethyst/ui/note/ReactionsRow.kt | 9 ++++-- .../amethyst/ui/note/ZapCustomDialog.kt | 28 ++++++++++++------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index 7a4067d6b8..8ffc1fcec7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -2067,11 +2067,16 @@ fun ZapAmountChoicePopup( val cashuEntries by cashuState.tokenEntries.collectAsStateWithLifecycle() val recipientInfo = author?.let { observeUserInfo(it, accountViewModel).value } val nutzapInfo = author?.let { observeNoteEvent(it.nutzapInfoNote, accountViewModel).value } + // Honors the user's "show on-chain wallet" preference: off hides the on-chain + // rail from the zap chips too, matching the wallet screen, profile chips, and + // Send Payment screen. + val showOnchainWallet by accountViewModel.settings.uiSettingsFlow.showOnchainWallet + .collectAsStateWithLifecycle() val railCapability = - remember(baseNote, onchainSupported, cashuMints, cashuEntries, recipientInfo, nutzapInfo) { + remember(baseNote, onchainSupported, showOnchainWallet, cashuMints, cashuEntries, recipientInfo, nutzapInfo) { val rc = RailCapabilityResolver.peek(baseNote, cashuState) - if (onchainSupported) rc else rc.copy(hasOnchain = false) + if (onchainSupported && showOnchainWallet) rc else rc.copy(hasOnchain = false) } val amountChoices = remember(zapAmountChoices) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt index 8c29e8e01c..6a62b3c88b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt @@ -71,6 +71,7 @@ import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties import androidx.core.net.toUri import androidx.lifecycle.ViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.model.Account @@ -180,6 +181,11 @@ fun ZapCustomDialog( // payment method, no "go back to Lightning" is offered here. var sendOnchain by remember { mutableStateOf(false) } + // Hides the "Send on-chain instead" hand-off when the user has turned the + // on-chain wallet off, matching every other on-chain surface. + val showOnchainWallet by accountViewModel.settings.uiSettingsFlow.showOnchainWallet + .collectAsStateWithLifecycle() + Dialog( onDismissRequest = { onClose() }, properties = @@ -353,16 +359,18 @@ fun ZapCustomDialog( // Hand off to the on-chain dialog with the entered amount + // message prefilled. Disabled while the amount is empty so the // user can't open a sheet that immediately gates on its own - // empty field. - TextButton( - onClick = { sendOnchain = true }, - enabled = postViewModel.canSend() && !baseNote.isDraft(), - modifier = - Modifier - .fillMaxWidth() - .padding(top = 4.dp), - ) { - Text(text = stringRes(id = R.string.send_onchain_instead)) + // empty field. Hidden entirely when the on-chain wallet is off. + if (showOnchainWallet) { + TextButton( + onClick = { sendOnchain = true }, + enabled = postViewModel.canSend() && !baseNote.isDraft(), + modifier = + Modifier + .fillMaxWidth() + .padding(top = 4.dp), + ) { + Text(text = stringRes(id = R.string.send_onchain_instead)) + } } } }