lightning-browser-extension icon indicating copy to clipboard operation
lightning-browser-extension copied to clipboard

Sometimes fiat value appear as 0 but should show none info or other kind of rendering

Open bitcoinuser opened this issue 2 years ago • 8 comments

Describe the bug

Sometimes I open Alby and I look to see how much the sats I have is representing in fiat. But sometimes maybe because it take some seconds to load or maybe because the fiat quote provider service is offline, the value appear as 0.

Screenshots of the changes [optional]

This screenshot is working ok, I couldn't take a screenshot reproducing the problem

Captura de tela de 2022-10-11 14-05-12

To Reproduce

The problem is hard to reproduce, maybe when fiat quote provider is slow or offline

Expected behavior

Not show 0 but instead show none information or some other kind of rendering.

Alby information

  • Alby Version: 1.17

bitcoinuser avatar Oct 11 '22 17:10 bitcoinuser

I feel it shows 0 because initialState of currencyRate is set to be 0 https://github.com/getAlby/lightning-browser-extension/blob/49705ab42ed5f9efaeb4c1d21c7832610f0d1e2e/src/app/context/SettingsContext.tsx#L30

Here it is multiplying the currency rate with the amount, which might result in this 0 value shown in the above issue. https://github.com/getAlby/lightning-browser-extension/blob/bbe56b879e50e4650519946bb65e0122d13ef168/src/common/utils/currencyConvert.ts#L7

Initial stage of fiatBalance : https://github.com/getAlby/lightning-browser-extension/blob/5156710bce3f21ce543a0f2fda89f0db2e724318/src/app/context/AccountContext.tsx#L53

We can add a check when we have some satsBalance and fiatBalance is 0, we can show loading icon like this

vaibhavgarg237 avatar Oct 11 '22 18:10 vaibhavgarg237

@bitcoinuser is the 0 usually replaced by a fiat value after some time/seconds or does it stay?
If this just shows during loading we could i.e. just show ... if fiat is 0 as a first fix. No need to add a spinner I think.

escapedcat avatar Oct 12 '22 04:10 escapedcat

is the 0 usually replaced by a fiat value after some time/seconds or does it stay?

The 0 is replaced by fiat after some time.

If this just shows during loading we could i.e. just show ... if fiat is 0 as a first fix. No need to add a spinner I think.

Agree

bitcoinuser avatar Oct 12 '22 14:10 bitcoinuser

yes, esp. in slow connections this happens and is visible.

bumi avatar Oct 12 '22 14:10 bumi

I feel we can change this with below mentioned changes in the image

Current Code: https://github.com/getAlby/lightning-browser-extension/blob/5156710bce3f21ce543a0f2fda89f0db2e724318/src/app/components/AccountMenu/index.tsx#L95-L97

Proposed Changes: image

vaibhavgarg237 avatar Oct 12 '22 15:10 vaibhavgarg237

Hm, currency depends on the settings. So checking for i.e. $ will not cover all cases, right?
Play around with the currencies in "settings".
Wanna check what solution might work better here?

escapedcat avatar Oct 13 '22 03:10 escapedcat

Hm, currency depends on the settings. So checking for i.e. $ will not cover all cases, right?

Oh I forgot that one. Will make it dynamic.

vaibhavgarg237 avatar Oct 13 '22 03:10 vaibhavgarg237

@escapedcat I have opened a PR for this issue with the proposed changes. Can you assign this issue to me?

vaibhavgarg237 avatar Oct 13 '22 17:10 vaibhavgarg237