Skip to content

Commit

Permalink
update transactions when going back online
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryn committed Jun 21, 2018
1 parent bca1ac5 commit 2c59b8b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/status_im/chat/models/message.cljs
Expand Up @@ -404,10 +404,10 @@

;; dispatch :update-transactions to update confirmations count
;; to verify tx initiated with /send command is confirmed
(defn update-transactions [command-name tx-hash {:keys [with-delay?]} _]
(defn update-transactions [command-name tx-hash {:keys [with-delay?]} cofx]
(when (and tx-hash
(= command-name constants/command-send))
(cond-> {:dispatch [:update-transactions]}
(cond-> {:update-transactions-fx cofx}
with-delay?
(assoc :utils/dispatch-later [{:ms 30000
:dispatch [:update-transactions]}
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/network/events.cljs
Expand Up @@ -33,7 +33,8 @@
{:db (assoc db :network-status (if is-connected? :online :offline))}
(inbox/request-messages))
is-connected?
(assoc :drain-mixpanel-events nil))))
(assoc :drain-mixpanel-events nil
:update-transactions-fx cofx))))

(handlers/register-handler-fx
::update-network-status
Expand Down
11 changes: 8 additions & 3 deletions src/status_im/ui/screens/wallet/events.cljs
Expand Up @@ -138,9 +138,9 @@
(assoc-in [:wallet :balance-loading?] true)
(assoc :prices-loading? true))}))))

(handlers/register-handler-fx
:update-transactions
(fn [{{:keys [network network-status web3] :as db} :db} _]
(re-frame/reg-fx
:update-transactions-fx
(fn [{{:keys [network network-status web3] :as db} :db}]
(when (not= network-status :offline)
(let [network (get-in db [:account/account :networks network])
chain (ethereum/network->chain-keyword network)
Expand All @@ -156,6 +156,11 @@
(clear-error-message :transactions-update)
(assoc-in [:wallet :transactions-loading?] true))}))))

(handlers/register-handler-fx
:update-transactions
(fn [cofx _]
{:update-transactions-fx cofx}))

(defn combine-entries [transaction token-transfer]
(merge transaction (select-keys token-transfer
(if (= :ETH (:symbol transaction))
Expand Down

0 comments on commit 2c59b8b

Please sign in to comment.