Skip to content

fix(amount-entry): reset amount when the selected token changes - #1144

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/reset-amount-on-token-change
Jul 24, 2026
Merged

fix(amount-entry): reset amount when the selected token changes#1144
bmc08gt merged 1 commit into
code/cashfrom
fix/reset-amount-on-token-change

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

What

Reset the entered/selected amount when the token changes, mirroring the existing behaviour for a region/currency change.

Previously, switching tokens re-denominated an amount entry but left the typed value in place, so an amount entered in one token was silently reinterpreted in another.

Changes

  • AmountEntryDelegate — new optional tokenChanges: Flow<*> trigger. Its init now resets the keypad on either a preferred-rate change (region/currency, existing) or a token change, via merge(observePreferredRate(), tokenChanges.distinctUntilChanged().drop(1)). drop(1) skips the initial token emission so an in-flight prefill isn't wiped on construction.
  • Give-cash (CashScreenViewModel) and chat amount entry (ChatViewModel) pass tokenChanges = tokenCoordinator.observeSelectedTokenMint() — both are driven by the global selected token.
  • Tip user modal (TippingCoordinator) — new init observer on the selected token that clears the modal's selected TipAmount (selectAmount(null)), the non-keypad counterpart to the delegate reset.

Intentionally excluded

  • Withdrawal and Swap — their token is pinned per-flow (e.g. WithdrawalStep.Amount(mint)), not the global selected token, so a global change must not reset their amount.
  • Tip amount-entry keypad — no in-screen token picker; the ViewModel is recreated per open.

Testing

  • :apps:flipcash:shared:amount-entry, :shared:tipping, :features:cash, :features:messenger compile.
  • :shared:tipping and :features:cash unit tests pass.

Switching tokens re-denominates an amount entry, so an amount typed in one
token was being silently reinterpreted in another. Mirror the existing
region/currency reset behaviour:

- AmountEntryDelegate gains an optional `tokenChanges` trigger; its init now
  resets the keypad on either a preferred-rate change or a token change.
  Wired into the give-cash and chat amount entries (global selected token).
- TippingCoordinator clears the tip modal's selected amount on token change.

Pinned-token flows (withdrawal, swap) and the picker-less tip keypad screen
are intentionally left untouched.
@github-actions github-actions Bot added area: payments Payments, transfers, intents, billing type: fix Bug fix labels Jul 24, 2026
@bmc08gt
bmc08gt merged commit feba193 into code/cash Jul 24, 2026
3 checks passed
@bmc08gt
bmc08gt deleted the fix/reset-amount-on-token-change branch July 24, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: payments Payments, transfers, intents, billing type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant