Allow only one wallet transactions sync loop

Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
Dmitry Novotochinov 2018-07-25 12:11:07 +02:00
parent 0aaf20911a
commit 063ed16c47
No known key found for this signature in database
GPG Key ID: 43D1DAF5AD39C927
3 changed files with 14 additions and 4 deletions

View File

@ -332,7 +332,7 @@
[:update-wallet]
[:update-transactions]
(when platform/mobile? [:get-fcm-token])
[:sync-wallet-transactions]
[:start-wallet-transactions-sync]
[:update-sign-in-time]]
(seq events-after) (into events-after))}))

View File

@ -477,6 +477,13 @@
(handlers/register-handler-fx
:sync-wallet-transactions
(fn [cofx _]
(wallet.transactions/sync cofx)))
(handlers/register-handler-fx
:start-wallet-transactions-sync
(fn [cofx _]
(when-not (get-in cofx [:db :wallet :transactions-sync-started?])
(handlers-macro/merge-fx cofx
(wallet.transactions/load-missing-chat-transactions)
(wallet.transactions/sync))))
(wallet.transactions/sync)
(wallet.transactions/set-sync-started)))))

View File

@ -88,6 +88,9 @@
(< sync-interval-ms
(- (time/timestamp) last-updated-at)))))
(defn set-sync-started [{:keys [db]}]
{:db (assoc-in db [:wallet :transactions-sync-started?] true)})
; Fetch updated data for any unconfirmed transactions or incoming chat transactions missing in wallet
; and schedule new recurring sync request
(defn sync [{:keys [db] :as cofx}]