[#11502] Handle tx fetching failure

This commit is contained in:
Roman Volosovskyi 2020-12-02 13:38:28 +02:00
parent eaf463395a
commit aac7a97e13
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
6 changed files with 56 additions and 10 deletions

View File

@ -59,7 +59,9 @@
[{:keys [db]} accounts]
(log/debug "[wallet-subs] recent-history-fetching-started"
"accounts" accounts)
{:db (transactions/update-fetching-status db accounts :recent? true)})
{:db (-> db
(transactions/update-fetching-status accounts :recent? true)
(assoc :wallet/recent-history-fetching-started? true))})
(fx/defn recent-history-fetching-ended
[{:keys [db] :as cofx} {:keys [accounts blockNumber]}]
@ -73,7 +75,9 @@
wallet/remove-transactions-since-block blockNumber)
(transactions/update-fetching-status accounts :recent? false)
(dissoc :wallet/waiting-for-recent-history?
:wallet/refreshing-history?))
:wallet/refreshing-history?
:wallet/fetching-error
:wallet/recent-history-fetching-started?))
:transactions/get-transfers
{:chain-tokens (:wallet/all-tokens db)
:addresses (reduce
@ -90,6 +94,13 @@
:historical? true}}
(wallet.core/restart-wallet-service-default)))
(fx/defn fetching-error
[{:keys [db] :as cofx} {:keys [message]}]
(fx/merge
cofx
{:db (assoc db :wallet/fetching-error message)}
(wallet.core/stop-wallet)))
(fx/defn new-wallet-event
[cofx {:keys [type blockNumber accounts newTransactions] :as event}]
(log/debug "[wallet-subs] new-wallet-event"
@ -101,4 +112,5 @@
"reorg" (reorg cofx event)
"recent-history-fetching" (recent-history-fetching-started cofx accounts)
"recent-history-ready" (recent-history-fetching-ended cofx event)
"fetching-history-error" (fetching-error cofx event)
(log/warn ::unknown-wallet-event :type type :event event)))

View File

@ -171,6 +171,7 @@
(reg-root-key-sub :wallet/favourites :wallet/favourites)
(reg-root-key-sub :wallet/refreshing-history? :wallet/refreshing-history?)
(reg-root-key-sub :wallet/buy-crypto-hidden :wallet/buy-crypto-hidden)
(reg-root-key-sub :wallet/fetching-error :wallet/fetching-error)
;;commands
(reg-root-key-sub :commands/select-account :commands/select-account)

View File

@ -18,6 +18,7 @@
[status-im.wallet.utils :as wallet.utils]
[status-im.ui.components.tabs :as tabs]
[quo.react-native :as rn]
[quo.design-system.colors :as quo-colors]
[status-im.utils.utils :as utils.utils])
(:require-macros [status-im.utils.views :as views]))
@ -212,7 +213,8 @@
:onRefresh refresh-action}]))
(views/defview account []
(views/letsubs [{:keys [name address] :as account} [:multiaccount/current-account]]
(views/letsubs [{:keys [name address] :as account} [:multiaccount/current-account]
fetching-error [:wallet/fetching-error]]
(let [anim-y (animation/create-value button-group-height)
scroll-y (animation/create-value 0)]
(anim-listener anim-y scroll-y)
@ -228,6 +230,30 @@
(and
@updates-counter
@(re-frame/subscribe [:wallet/refreshing-history?])))}
(when fetching-error
[react/view {:style {:flex 1
:align-items :center
:margin 8}}
[icons/icon
:main-icons/warning
{:color :red
:container-style {:background-color (quo-colors/get-color :negative-02)
:height 40
:width 40
:border-radius 20
:align-items :center
:justify-content :center}}]
[react/view
{:style {:justify-content :center
:align-items :center
:margin-top 8
:margin-horizontal 67.5
:text-align :center}}
[quo/text
{:color :secondary
:size :small
:style {:text-align :center}}
(i18n/label :t/transfers-fetching-failure)]]])
[react/view {:padding-left 16}
[react/scroll-view {:horizontal true}
[react/view {:flex-direction :row :padding-top 8 :padding-bottom 12}

View File

@ -557,8 +557,12 @@
#(re-frame.core/dispatch [::restart])
ms-20-min))]
{:db (-> db
(update :wallet dissoc :fetching)
(assoc :wallet-service/state :stopped)
(assoc :wallet-service/restart-timeout timeout))
(assoc :wallet-service/restart-timeout timeout)
(dissoc :wallet/recent-history-fetching-started?
:wallet/waiting-for-recent-history?
:wallet/refreshing-history?))
::stop-wallet nil}))
(fx/defn start-wallet
@ -620,9 +624,11 @@
(fx/defn restart-on-pull
{:events [:wallet.ui/pull-to-refresh-history]}
[{:keys [db now] :as cofx}]
(let [last-pull (get db :wallet/last-pull-time)
watching? (get db :wallet/watch-txs)]
(let [last-pull (get db :wallet/last-pull-time)
watching? (get db :wallet/watch-txs)
fetching-history? (get db :wallet/recent-history-fetching-started?)]
(when (and (not watching?)
(not fetching-history?)
(or (not last-pull)
(> (- now last-pull) pull-to-refresh-cooldown-period)))
(fx/merge

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im",
"repo": "status-go",
"version": "v0.65.0",
"commit-sha1": "cdca42b90f7fd5f302a5eb31802b9ae526d566d7",
"src-sha256": "1qpq9y099bfa6x36afbimn2p5inzrsgbb8qzigmchl513mkhp5s1"
"version": "v0.66.1",
"commit-sha1": "bf703254ba242293c39abd9102420be9e2cc2e25",
"src-sha256": "1xfrgil9nz5q2jmq86v4fhhkz0gnq02dhyq8bnavvi5j7qg1saw1"
}

View File

@ -1349,5 +1349,6 @@
"has-permissions": "has permission to access",
"connect-wallet": "Connect wallet",
"open-chat": "Open chat",
"favourite-description": "Your favourite websites will appear here"
"favourite-description": "Your favourite websites will appear here",
"transfers-fetching-failure": "Transfers history could not be updated. Check your connection and pull down to try again"
}