wallet tokens aren't retrieved on currency change, only prices.

This commit is contained in:
Volodymyr Kozieiev 2024-11-21 15:02:05 +00:00
parent 041e48c4e2
commit 1538fb47a3
No known key found for this signature in database
GPG Key ID: 82B04968DF4C0535
1 changed files with 26 additions and 3 deletions

View File

@ -139,10 +139,33 @@
:on-success #(log/debug "mnemonic was marked as shown")
:on-error #(log/error "mnemonic was not marked as shown" %)}]]]}))
(defn token-symbols-from-accounts
[accounts]
(->> accounts
vals
(reduce (fn [acc account]
(->> account
:tokens
(map :symbol)
(into acc)))
#{})
vec))
(rf/reg-event-fx :profile.settings/update-currency
(fn [_ [currency]]
(fn [{:keys [db]} [currency]]
(let [accounts (get-in db [:wallet :accounts])
symbols (token-symbols-from-accounts accounts)]
{:fx [[:dispatch [:profile.settings/profile-update :currency currency]]
[:dispatch [:wallet/get-wallet-token-for-all-accounts]]]}))
[:effects.wallet.tokens/fetch-market-values
{:symbols symbols
:currency currency
:on-success [:wallet.tokens/store-market-values]
:on-error [:wallet.tokens/fetch-market-values-failed]}]
[:effects.wallet.tokens/fetch-prices
{:symbols symbols
:currencies [constants/profile-default-currency currency]
:on-success [:wallet.tokens/store-prices]
:on-error [:wallet.tokens/fetch-prices-failed]}]]})))
;; Logout process
(rf/reg-event-fx