Skip to content

Commit

Permalink
add config for all balances
Browse files Browse the repository at this point in the history
  • Loading branch information
mmilad75 committed Apr 25, 2024
1 parent 8d63575 commit 7c5979e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/status_im/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@
(def fetch-messages-enabled? (enabled? (get-config :FETCH_MESSAGES_ENABLED "1")))
(def test-networks-enabled? (enabled? (get-config :TEST_NETWORKS_ENABLED "0")))

(def include-watch-only-balance-in-total? false)
(def include-watch-only-balance-in-total? true)
2 changes: 1 addition & 1 deletion src/status_im/contexts/wallet/home/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
networks (rf/sub [:wallet/selected-network-details])
account-cards-data (rf/sub [:wallet/account-cards-data])
cards (conj account-cards-data (new-account-card-data))
{:keys [formatted-balance]} (rf/sub [:wallet/total-owned-accounts-balance])]
{:keys [formatted-balance]} (rf/sub [:wallet/aggregated-token-values-and-balance])]
(rn/use-effect (fn []
(when (and @account-list-ref (pos? (count cards)))
(.scrollToOffset ^js @account-list-ref
Expand Down
19 changes: 4 additions & 15 deletions src/status_im/subs/wallet/wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,10 @@
(rf/reg-sub
:wallet/aggregated-tokens
:<- [:wallet/accounts]
(fn [accounts]
(utils/aggregate-tokens-for-all-accounts accounts)))
:<- [:wallet/accounts-without-watched-accounts]
(fn [[all-accounts owned-accounts]]
(let [accounts (if config/include-watch-only-balance-in-total? all-accounts owned-accounts)]
(utils/aggregate-tokens-for-all-accounts accounts))))

(rf/reg-sub
:wallet/aggregated-tokens-in-selected-networks
Expand All @@ -320,19 +322,6 @@
:currency-symbol currency-symbol})
aggregated-tokens)})))

(rf/reg-sub
:wallet/total-owned-accounts-balance
:<- [:wallet/accounts]
:<- [:wallet/accounts-without-watched-accounts]
:<- [:wallet/balances-in-selected-networks]
:<- [:profile/currency-symbol]
(fn [[all-accounts owned-accounts balances currency-symbol]]
(let [accounts (if config/include-watch-only-balance-in-total? all-accounts owned-accounts)
raw-balance (utils/calculate-balance-from-accounts accounts balances)
formatted-balance (utils/prettify-balance currency-symbol raw-balance)]
{:balance raw-balance
:formatted-balance formatted-balance})))

(rf/reg-sub
:wallet/network-preference-details
:<- [:wallet/current-viewing-account]
Expand Down

0 comments on commit 7c5979e

Please sign in to comment.