From 85ece39ece5ebae4f6246f28642ca3cab7303795 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 18 Apr 2026 14:19:51 +0000 Subject: [PATCH] fix: hide payment targets button on profile when user has none Previously the wallet icon always rendered on the profile header and opened a dialog showing "No payment targets" when empty. Skip rendering the button entirely when the user has no payment targets. https://claude.ai/code/session_01X51KAzYWnqxkr5WdCm4a7J --- .../loggedIn/profile/header/PaymentButton.kt | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/PaymentButton.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/PaymentButton.kt index 84e3a2cf4f..cc79594746 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/PaymentButton.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/PaymentButton.kt @@ -64,7 +64,9 @@ fun PaymentButton( remember(note) { (note?.event as? PaymentTargetsEvent)?.paymentTargets() ?: emptyList() } - PaymentButtonWithTargets(targets) + if (targets.isNotEmpty()) { + PaymentButtonWithTargets(targets) + } } } @@ -94,31 +96,22 @@ fun PaymentButtonWithTargets(targets: List) { onDismiss = { expanded = false }, ) { M3ActionSection { - if (targets.isEmpty()) { + targets.forEach { target -> M3ActionRow( icon = Icons.Outlined.AccountBalanceWallet, - text = stringRes(R.string.no_payment_targets_message), - enabled = false, - onClick = {}, + text = "${target.type.replaceFirstChar(Char::titlecase)}: ${target.authority}", + onClick = { + expanded = false + try { + val intent = Intent(Intent.ACTION_VIEW, "payto://${target.type}/${target.authority}".toUri()) + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + context.startActivity(intent) + } catch (e: Exception) { + if (e is kotlinx.coroutines.CancellationException) throw e + errorMessage = stringRes(context, R.string.no_payment_app_found) + } + }, ) - } else { - targets.forEach { target -> - M3ActionRow( - icon = Icons.Outlined.AccountBalanceWallet, - text = "${target.type.replaceFirstChar(Char::titlecase)}: ${target.authority}", - onClick = { - expanded = false - try { - val intent = Intent(Intent.ACTION_VIEW, "payto://${target.type}/${target.authority}".toUri()) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK - context.startActivity(intent) - } catch (e: Exception) { - if (e is kotlinx.coroutines.CancellationException) throw e - errorMessage = stringRes(context, R.string.no_payment_app_found) - } - }, - ) - } } } }