Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend/account-summary: add coins total balance #2573

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

strmci
Copy link
Collaborator

@strmci strmci commented Feb 23, 2024

Before this update, the account summary didn't show total coin balances, especially when managing multiple wallets with the watch-only feature. This commit addresses that by adding a new coin balances table below the chart. It appears only when there are multiple wallets in the portfolio.

Restored backend code previously removed in commit d8c6ba0.

@strmci strmci force-pushed the add_coins_total_balance branch from 77d0103 to 1744a10 Compare February 23, 2024 13:38
@strmci strmci changed the title fronted/account-summary: add coins total balance frontend/account-summary: add coins total balance Feb 23, 2024
@strmci strmci requested a review from thisconnect February 23, 2024 13:40
@strmci strmci force-pushed the add_coins_total_balance branch 4 times, most recently from f6cf02a to d2e7dfa Compare February 23, 2024 14:29
@strmci strmci force-pushed the add_coins_total_balance branch from d2e7dfa to 9b1d8d9 Compare February 26, 2024 10:58
@strmci
Copy link
Collaborator Author

strmci commented Feb 27, 2024

@thisconnect updated, PTAL

@thisconnect
Copy link
Collaborator

I've only tested with with a BitBox and a remembered wallet. Looks good. Maybe a bit unrelated but when I unplug the device, the chart sometimes looks funny and goes into a bit a weird state.

PR #2635 should properly mount and unmount the chart if there are changes. So I think we should merge #2635 first.

@thisconnect thisconnect requested a review from Beerosagos March 19, 2024 18:17
@thisconnect
Copy link
Collaborator

@strmci is this the same backend code that got removed in an earlier commit?

@thisconnect
Copy link
Collaborator

@strmci please rebase

@strmci
Copy link
Collaborator Author

strmci commented Mar 20, 2024

@strmci is this the same backend code that got removed in an earlier commit?

yes, it is the same code

@strmci strmci force-pushed the add_coins_total_balance branch from 9b1d8d9 to 84690cb Compare March 20, 2024 07:36
@thisconnect
Copy link
Collaborator

yes, it is the same code

could you add the commit hash where it got removed in your commit message, so it is easier to review?

@strmci strmci force-pushed the add_coins_total_balance branch from 84690cb to 3c748d7 Compare March 20, 2024 07:50
@strmci
Copy link
Collaborator Author

strmci commented Mar 20, 2024

@strmci please rebase

could you add the commit hash where it got removed in your commit message, so it is easier to review?

@thisconnect rebased and commit hash added, PTAL

Copy link
Collaborator

@thisconnect thisconnect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frontend tested LGTM

defering to @Beerosagos to take a look at backend change

@@ -749,6 +750,59 @@ func (handlers *Handlers) getAccountsBalance(*http.Request) (interface{}, error)
return totalAmount, nil
}

// getCoinsTotalBalance returns the total balances grouped by coins.
func (handlers *Handlers) getCoinsTotalBalance(_ *http.Request) (interface{}, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just merged a PR that creates a new method backend.accountFiatBalance (https://github.com/digitalbitbox/bitbox-wallet-app/blob/master/backend/accounts.go#L230). It would be nice to refactor getCoinsTotalBalance to exploit the function and avoid code duplication.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it would be nice to add unit tests for getCoinsTotalBalance, but it's probably easier to do it after #2633 gets merged

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to refactor getCoinsTotalBalance to exploit the function and avoid code duplication.

Never mind, I didn't realize that the function was providing the fiat conversions for each enabled fiat and that now it is possible to cycle across fiat units also in the account summary.

@strmci strmci force-pushed the add_coins_total_balance branch from 3c748d7 to ce1bb69 Compare March 26, 2024 10:40
Before this update, the account summary didn't show total coin
balances, especially when managing multiple wallets with the
watch-only feature. This commit addresses that by adding a new
coin balances table below the chart. It appears only when there
are multiple wallets in the portfolio.

Restored backend code previously removed in commit d8c6ba0.
@strmci strmci force-pushed the add_coins_total_balance branch from ce1bb69 to 8239c92 Compare March 26, 2024 11:51
Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend looks good. It would be even nicer to move the core of the function from handlers to backend/accounts.go and add unit tests (see my previous comment about it). But we can do it in a separate PR

@strmci strmci merged commit 12ba2a4 into BitBoxSwiss:master Mar 26, 2024
5 checks passed
@benma
Copy link
Contributor

benma commented Apr 25, 2024

This was missing a CHANGELOG entry, see also: #2613

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.

4 participants