From c8465741554403a783a2092ed54e9da1055978d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Thor=C3=A9n?= Date: Thu, 21 Sep 2017 20:01:20 +0200 Subject: [PATCH] Fix portfolio change to 0 if balance is zero If you don't have money in your balance, your "portfolio" change is nothing. - Positive portfolio change includes if it is zero --- src/status_im/ui/screens/wallet/main/views.cljs | 2 +- src/status_im/ui/screens/wallet/subs.cljs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/status_im/ui/screens/wallet/main/views.cljs b/src/status_im/ui/screens/wallet/main/views.cljs index 21c73c01b4..3dffd9e376 100644 --- a/src/status_im/ui/screens/wallet/main/views.cljs +++ b/src/status_im/ui/screens/wallet/main/views.cljs @@ -45,7 +45,7 @@ transaction-history-action]]]) (defn- change-display [change] - (let [pos-change? (pos? change)] + (let [pos-change? (or (pos? change) (zero? change))] [react/view {:style (if pos-change? wallet.styles/today-variation-container-positive wallet.styles/today-variation-container-negative)} diff --git a/src/status_im/ui/screens/wallet/subs.cljs b/src/status_im/ui/screens/wallet/subs.cljs index 2802b90ce4..cc9a4d21fa 100644 --- a/src/status_im/ui/screens/wallet/subs.cljs +++ b/src/status_im/ui/screens/wallet/subs.cljs @@ -46,11 +46,14 @@ (reg-sub :portfolio-change :<- [:price] :<- [:last-day] - (fn [[price last-day]] + :<- [:balance] + (fn [[price last-day balance]] (when (and price last-day) - (-> (money/percent-change price last-day) - (money/with-precision 2) - .toNumber)))) + (if (> balance 0) + (-> (money/percent-change price last-day) + (money/with-precision 2) + .toNumber) + 0)))) (reg-sub :prices-loading? (fn [db]