Skip to content

Commit 26c0dd3

Browse files
committed
fix(chat): enforce tip minimum on send with an alert
Guard the send path: when the chat is a tip DM with a minimum and the entered amount is below it, surface a "<min> Minimum" alert and abort the send instead of proceeding. Reword the tip-minimum error strings to match. Pairs with the slide label simplification — the minimum is now enforced at send time rather than implied by a dedicated "Swipe to Tip" label.
1 parent fe0f6f2 commit 26c0dd3

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

apps/flipcash/core/src/main/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,8 @@
899899
<string name="action_swipeToTip">Swipe to Tip</string>
900900
<string name="content_description_customTipAmount">Enter a custom amount</string>
901901
<string name="subtitle_tipHintMinimum">Minimum tip %1$s</string>
902-
<string name="error_title_tipMinimum">Tips Start at %1$s</string>
903-
<string name="error_description_tipMinimum">Enter a larger amount to send this tip</string>
902+
<string name="error_title_tipMinimum">%1$s Minimum</string>
903+
<string name="error_description_tipMinimum">Increase the amount to send</string>
904904
<string name="label_viaTipCard">via Tip Card</string>
905905

906906
<string name="title_block">Block</string>

apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/ChatViewModel.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,17 @@ internal class ChatViewModel @Inject constructor(
665665
val source = owner.withTimelockForToken(token)
666666

667667
val balance = tokenCoordinator.balanceForToken(token)
668+
669+
val minimum = minAmountFlow.value
670+
if (minimum != null && amount.valueLessThan(minimum)) {
671+
dispatchEvent(Event.SendStateUpdated())
672+
BottomBarManager.showAlert(
673+
title = resources.getString(R.string.error_title_tipMinimum, minimum.formatted()),
674+
message = resources.getString(R.string.error_description_tipMinimum),
675+
)
676+
return@launch
677+
}
678+
668679
val verifiedFiat = verifiedFiatCalculator.compute(
669680
amount = amount,
670681
token = token,

0 commit comments

Comments
 (0)