From 156089b07bec8069cfb0323c1e5ff492eb27d73d Mon Sep 17 00:00:00 2001 From: Eric Dvorsak Date: Mon, 8 Jan 2018 14:20:57 +0100 Subject: [PATCH] [fix #2314] do not try to update wallet and transactions when offline --- src/status_im/ui/screens/wallet/events.cljs | 58 +++++++++++---------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/status_im/ui/screens/wallet/events.cljs b/src/status_im/ui/screens/wallet/events.cljs index ff9167b7b2..a7ce74bc05 100644 --- a/src/status_im/ui/screens/wallet/events.cljs +++ b/src/status_im/ui/screens/wallet/events.cljs @@ -86,37 +86,39 @@ (handlers/register-handler-fx :update-wallet - (fn [{{:keys [web3 accounts/current-account-id network] :as db} :db} [_ symbols]] - {:get-balance {:web3 web3 - :account-id current-account-id - :success-event :update-balance-success - :error-event :update-balance-fail} - :get-tokens-balance {:web3 web3 - :account-id current-account-id - :symbols symbols - :chain (ethereum/network->chain-keyword network) - :success-event :update-token-balance-success - :error-event :update-token-balance-fail} - :get-prices {:from "ETH" - :to "USD" - :success-event :update-prices-success - :error-event :update-prices-fail} - :db (-> db - (clear-error-message :prices-update) - (clear-error-message :balance-update) - (assoc-in [:wallet :balance-loading?] true) - (assoc :prices-loading? true))})) + (fn [{{:keys [web3 accounts/current-account-id network network-status] :as db} :db} [_ symbols]] + (when-not (= network-status :offline) + {:get-balance {:web3 web3 + :account-id current-account-id + :success-event :update-balance-success + :error-event :update-balance-fail} + :get-tokens-balance {:web3 web3 + :account-id current-account-id + :symbols symbols + :chain (ethereum/network->chain-keyword network) + :success-event :update-token-balance-success + :error-event :update-token-balance-fail} + :get-prices {:from "ETH" + :to "USD" + :success-event :update-prices-success + :error-event :update-prices-fail} + :db (-> db + (clear-error-message :prices-update) + (clear-error-message :balance-update) + (assoc-in [:wallet :balance-loading?] true) + (assoc :prices-loading? true))}))) (handlers/register-handler-fx :update-transactions - (fn [{{:keys [accounts/current-account-id network] :as db} :db} _] - {:get-transactions {:account-id current-account-id - :network network - :success-event :update-transactions-success - :error-event :update-transactions-fail} - :db (-> db - (clear-error-message :transaction-update) - (assoc-in [:wallet :transactions-loading?] true))})) + (fn [{{:keys [accounts/current-account-id network network-status] :as db} :db} _] + (when-not (= network-status :offline) + {:get-transactions {:account-id current-account-id + :network network + :success-event :update-transactions-success + :error-event :update-transactions-fail} + :db (-> db + (clear-error-message :transaction-update) + (assoc-in [:wallet :transactions-loading?] true))}))) (handlers/register-handler-db :update-transactions-success