diff --git a/src/status_im/ui/screens/wallet/main/views.cljs b/src/status_im/ui/screens/wallet/main/views.cljs index ee111216ba..34086d0fa3 100644 --- a/src/status_im/ui/screens/wallet/main/views.cljs +++ b/src/status_im/ui/screens/wallet/main/views.cljs @@ -176,7 +176,7 @@ [transactions.views/history-list true]] [react/scroll-view {:refresh-control (reagent/as-element - [react/refresh-control {:on-refresh #(re-frame/dispatch [:update-wallet]) + [react/refresh-control {:on-refresh #(re-frame/dispatch [:wallet.ui/pull-to-refresh]) :tint-color :white :refreshing false}])} (if error-message diff --git a/src/status_im/ui/screens/wallet/settings/events.cljs b/src/status_im/ui/screens/wallet/settings/events.cljs index e8968f4bad..c548e1c7fd 100644 --- a/src/status_im/ui/screens/wallet/settings/events.cljs +++ b/src/status_im/ui/screens/wallet/settings/events.cljs @@ -12,3 +12,8 @@ :configure-token-balance-and-visibility (fn [cofx [_ symbol balance]] (models/configure-token-balance-and-visibility symbol balance accounts.update/update-settings cofx))) + +(handlers/register-handler-fx + :wallet.ui/pull-to-refresh + (fn [cofx _] + (models/wallet-autoconfig-tokens cofx))) diff --git a/src/status_im/ui/screens/wallet/settings/models.cljs b/src/status_im/ui/screens/wallet/settings/models.cljs index 000676e6f3..194dc65ece 100644 --- a/src/status_im/ui/screens/wallet/settings/models.cljs +++ b/src/status_im/ui/screens/wallet/settings/models.cljs @@ -24,15 +24,17 @@ (wallet.events/update-token-balance-success symbol balance))) (defn wallet-autoconfig-tokens [{:keys [db]}] - (let [{:keys [account/account web3]} db + (let [{:keys [account/account web3 network-status]} db network (get (:networks account) (:network account)) chain (ethereum/network->chain-keyword network) contracts (->> (tokens/tokens-for chain) (remove :hidden?))] - (doseq [{:keys [address symbol]} contracts] - ;;TODO(goranjovic): move `get-token-balance` function to wallet models - (wallet.events/get-token-balance {:web3 web3 - :contract address - :account-id (:address account) - :on-success #(when (> % 0) - (re-frame/dispatch [:configure-token-balance-and-visibility symbol %]))})))) + (when-not (= network-status :offline) + (doseq [{:keys [address symbol]} contracts] + ;;TODO(goranjovic): move `get-token-balance` function to wallet models + (wallet.events/get-token-balance {:web3 web3 + :contract address + :account-id (:address account) + :on-error #(re-frame/dispatch [:update-token-balance-fail symbol %]) + :on-success #(when (> % 0) + (re-frame/dispatch [:configure-token-balance-and-visibility symbol %]))})))))