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
This commit is contained in:
Claude
2026-04-18 14:19:51 +00:00
parent 9ac39069bb
commit 85ece39ece
@@ -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<PaymentTarget>) {
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)
}
},
)
}
}
}
}