fix(amount-entry): reset amount when the selected token changes - #1144
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 optionaltokenChanges: Flow<*>trigger. Itsinitnow resets the keypad on either a preferred-rate change (region/currency, existing) or a token change, viamerge(observePreferredRate(), tokenChanges.distinctUntilChanged().drop(1)).drop(1)skips the initial token emission so an in-flight prefill isn't wiped on construction.CashScreenViewModel) and chat amount entry (ChatViewModel) passtokenChanges = tokenCoordinator.observeSelectedTokenMint()— both are driven by the global selected token.TippingCoordinator) — newinitobserver on the selected token that clears the modal's selectedTipAmount(selectAmount(null)), the non-keypad counterpart to the delegate reset.Intentionally excluded
WithdrawalStep.Amount(mint)), not the global selected token, so a global change must not reset their amount.Testing
:apps:flipcash:shared:amount-entry,:shared:tipping,:features:cash,:features:messengercompile.:shared:tippingand:features:cashunit tests pass.