Our chart uses daily as its source default state value, which isn't always useful. Instead, we need to make sure to set this source state to the appropriate value according to the stored chartDisplay in the context, since the source state is used to populate chart data,etc.
Other than as a best practice, this fixes an edge case bug. Such as wrong data & percentage difference displayed when user does the following:
picks USD as default currency,
navigate to a different page,
and going back to account summary.
The above only happens when "USD" is picked because of the following line:
if (this.props.data.chartFiat !== prev.data.chartFiat) {
this.reinitializeChart();
}
This means, if other chartFiat is picked, it'll reinitializeChart() very quickly (thus unnoticable), and will use the already correct source state.
Our chart uses
daily
as itssource
default state value, which isn't always useful. Instead, we need to make sure to set thissource
state to the appropriate value according to the storedchartDisplay
in the context, since thesource
state is used to populate chart data,etc.Other than as a best practice, this fixes an edge case bug. Such as wrong data & percentage difference displayed when user does the following:
The above only happens when "USD" is picked because of the following line:
This means, if other
chartFiat
is picked, it'll reinitializeChart() very quickly (thus unnoticable), and will use the already correctsource
state.Bug fix preview:
[Before]:
https://github.com/BitBoxSwiss/bitbox-wallet-app/assets/28676406/cbf20a78-0355-4d11-ad8c-88ef3517a5bc
[After]:
https://github.com/BitBoxSwiss/bitbox-wallet-app/assets/28676406/962f6e2a-369b-41c8-bc31-4d1b1ab199c6