From f3b6f98079f1e18b4115b5a8abec07b73ae9b041 Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Mon, 6 May 2019 16:59:35 +0200 Subject: [PATCH] [#8107] Wallet balance is not updated when transaction is received Signed-off-by: Pedro Pombeiro --- src/status_im/ui/screens/wallet/main/views.cljs | 6 +++++- src/status_im/ui/screens/wallet/navigation.cljs | 13 ++++++++++++- .../ui/screens/wallet/transactions/views.cljs | 8 ++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/status_im/ui/screens/wallet/main/views.cljs b/src/status_im/ui/screens/wallet/main/views.cljs index 6f9614f970..db61cfc9d3 100644 --- a/src/status_im/ui/screens/wallet/main/views.cljs +++ b/src/status_im/ui/screens/wallet/main/views.cljs @@ -164,7 +164,11 @@ [react/scroll-view {:end-fill-color colors/white :refresh-control (reagent/as-element - [react/refresh-control {:on-refresh #(re-frame/dispatch [:wallet.ui/pull-to-refresh]) + [react/refresh-control {:on-refresh (fn [_] + ;;TODO temporay fix to update balance, should be fixed + ;;properly later + (re-frame/dispatch [:wallet.ui/pull-to-refresh]) + (re-frame/dispatch [:update-wallet])) :tint-color :white :refreshing false}])} (if error-message diff --git a/src/status_im/ui/screens/wallet/navigation.cljs b/src/status_im/ui/screens/wallet/navigation.cljs index 1a6fb5306c..5239b2e2d4 100644 --- a/src/status_im/ui/screens/wallet/navigation.cljs +++ b/src/status_im/ui/screens/wallet/navigation.cljs @@ -2,16 +2,27 @@ (:require [re-frame.core :as re-frame] [status-im.ui.screens.navigation :as navigation] [status-im.utils.ethereum.core :as ethereum] - [status-im.constants :as constants])) + [status-im.constants :as constants] + [status-im.utils.utils :as utils])) (defmethod navigation/preload-data! :wallet [db _] ;;TODO(goranjovic) - get rid of this preload hook completely + ;;TODO(andrey) - temporary "improvement" with timeout, to fix screen rendering, wallet update should be optimized + (utils/set-timeout (fn [] + (re-frame/dispatch [:wallet.ui/pull-to-refresh]) + (re-frame/dispatch [:update-wallet])) + 500) (assoc-in db [:wallet :current-tab] 0)) (defmethod navigation/preload-data! :wallet-stack [db _] ;;TODO(goranjovic) - get rid of this preload hook completely + ;;TODO(andrey) - temporary "improvement" with timeout, to fix screen rendering, wallet update should be optimized + (utils/set-timeout (fn [] + (re-frame/dispatch [:wallet.ui/pull-to-refresh]) + (re-frame/dispatch [:update-wallet])) + 500) (assoc-in db [:wallet :current-tab] 0)) (defmethod navigation/preload-data! :transactions-history diff --git a/src/status_im/ui/screens/wallet/transactions/views.cljs b/src/status_im/ui/screens/wallet/transactions/views.cljs index e3db415e6d..9648074b47 100644 --- a/src/status_im/ui/screens/wallet/transactions/views.cljs +++ b/src/status_im/ui/screens/wallet/transactions/views.cljs @@ -14,7 +14,8 @@ [status-im.utils.money :as money] [status-im.utils.ethereum.tokens :as tokens] [status-im.utils.ethereum.core :as ethereum] - [status-im.ui.screens.wallet.utils :as wallet.utils])) + [status-im.ui.screens.wallet.utils :as wallet.utils] + [status-im.utils.utils :as utils])) (defn history-action [filter?] (cond-> @@ -254,7 +255,9 @@ [react/view {:style components.styles/flex} [status-bar/status-bar] [toolbar/toolbar {} - toolbar/default-nav-back + [toolbar/nav-button (actions/back + ;;TODO temporary fix to update wallet balance, should be fixed properly later + (utils/set-timeout #(re-frame/dispatch [:update-wallet]) 500))] [toolbar/content-title (i18n/label :t/transaction-details)] (when transaction [toolbar/actions (details-action hash url)])] [react/scroll-view {:style components.styles/main-container} @@ -262,3 +265,4 @@ [details-confirmations confirmations confirmations-progress type] [react/view {:style styles/details-separator}] [details-list transaction]]])) +