[fix #2314] do not try to update wallet and transactions when offline

This commit is contained in:
Eric Dvorsak 2018-01-08 14:20:57 +01:00
parent dc61971608
commit 156089b07b
No known key found for this signature in database
GPG Key ID: 932AC1CE5F05DE0C
1 changed files with 30 additions and 28 deletions

View File

@ -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