Syrius: bug fusing widget resets address field

Problem

There is still an issue where if you enter the beneficiary address, entering the amount resets the beneficiary addy to the original one, and you need to change it again.

Cause

A widget’s state is stored in a State object, separating the widget’s state from its appearance. The state consists of values that can change, like a slider’s current value or whether a checkbox is checked. When the widget’s state changes, the state object calls setState(), telling the framework to redraw the widget.

Solution

Comment out the setState(() {}); prevents the redraw of the widget.

Implementation

https://github.com/KingGorrin/syrius/tree/fix-fusing-addr-reset

3 Likes

Ha, funny you raise this issue. I experienced this too last night. It took me a while to figure out what was happening. I eventually figured out I just needed to paste in the address, then the amount, and then could fuse. But it seemed strange.

Glad you raised this issue. It should be fixed b/ for a new user it could be frustrating for them.

You can open a PR and I’ll merge it.

1 Like

I can confirm this was fixed in the latest release on mac. But I found a new issue. Will create a separate post.

I don’t know where to post this, but can we have a toggle for notifications? Or maybe only get important notifications (sent/received txs, plasma generated…) ? I’m getting a notification for copying my address for example.

Yes, but it requires more time for implementation. Disabling notification should definitely be on a task list in the future.

OP correction.

What?

Under the plasma tab, where if you enter the beneficiary address, entering the amount resets the beneficiary address to the current selected address, and you need to change it again.

Why?

A widget’s state is stored in a State object, separating the widget’s state from its appearance. The state consists of values that can change, like a slider’s current value or whether a checkbox is checked. When the widget’s state changes, the state object calls setState(), telling the framework to redraw the widget.

The setState() is called when the amount changes, causing a redraw of the widget.

The beneficiary address is initialized in the build method. A redraw will initialize and consequently overwrite the beneficiary address to the currently selected address. Effectivly overwriting changes made to beneficiary address everytime the amount changes.

How?

By subscribing to the PlasmaBeneficiaryAddressNotifier in the initState method, will initializes the beneficiary address one time and overwrite it when the selected address changes and not when the widget gets rebuild.

Anything else?

Using Provider.of<>() within the initState method requires listen to be false.

The PlasmaBeneficiaryAddressNotifier ends up with multiple listeners when using an anonymous method which could introduce a memory leak.

Implementation

https://github.com/KingGorrin/syrius/tree/fix-fusing-addr-reset

1 Like