Skip to content

Fix/recipient locale change followup - #1481

Open
slopbot9k wants to merge 6 commits into
cypherstack:fix/recipient-locale-changefrom
slopbot9k:fix/recipient-locale-change-followup
Open

slopbot9k wants to merge 6 commits into
cypherstack:fix/recipient-locale-changefrom
slopbot9k:fix/recipient-locale-change-followup

Conversation

@slopbot9k

Copy link
Copy Markdown
Contributor

No description provided.

Emptying the fiat field cleared the crypto field but left
_amountToSend as zero. The unit change listener added in this branch
reformats whatever amount is stored, so switching units after clearing
the fiat field wrote "0" into a field the user had just emptied. Store
null instead, which is what the crypto-clear path already does.
Same fix as the token send views: emptying the fiat field set
pSendAmount to zero while the crypto field was blank, so a later unit
change reformatted that zero into the cleared field. Store null, which
matches the crypto-clear path.
The SOL token send views were still passing _cryptoAmountChanged as
onRelocalized, so a locale change rewrote the controller text and then
re-parsed that display text as a new edit. Use the same
_updateAmountDisplay lock as the other send views so the stored amount
is preserved and only the separator changes.
_updateAmountDisplay locks out _cryptoAmountChanged while it runs, so
the assignment inside it can no longer clear _xelisSendAll. The save
and restore around it was unreachable protection.
The mobile SOL token send view only subscribed to pAmountFormatter from
inside the fee FutureBuilder. Riverpod drops that subscription at the end
of every rebuild of the view and only restores it once the fee future has
completed, so a locale change that lands while a fee recalculation is
pending leaves the formatter dirty with no listeners. The fee row then
refreshes it from inside its own build, and the resulting markNeedsBuild
on the view trips Flutter's build-phase assertion in debug builds and
tests. The ETH token view already watches the formatter in its build
method and is not affected.

Watch the formatter once in the build method, where the view always holds
the subscription, and pass it into the fee row. Add a regression test that
edits and clears the fiat amount, then changes locale twice while the fee
recalculation is pending.
Type a fiat amount, clear it, then switch the display unit in the four
send views that reformat the stored amount on a unit change. The crypto
field must stay blank, and the main send views must store no amount.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant