schedule :check-sync outside callback (which can be not called after locking/unlocking phone)

This commit is contained in:
Roman Volosovskyi 2017-06-01 10:33:26 +03:00 committed by Roman Volosovskyi
parent 45a08d7643
commit ec469f59b1
1 changed files with 6 additions and 7 deletions

View File

@ -74,18 +74,17 @@
(when (and (not= sync-data state) (= :in-progress new-state))
(dispatch [:set :sync-data state]))
(when (not= sync-state new-state)
(dispatch [:set :sync-state new-state]))
(let [timeout (if (#{:done :synced} new-state) 60 10)]
(s/execute-later #(dispatch [:check-sync]) (s/s->ms timeout)))))))
(dispatch [:set :sync-state new-state]))))))
(register-handler :check-sync
(u/side-effect!
(fn [{:keys [web3] :as db}]
(if web3
(.getSyncing
(.-eth web3)
(fn [error sync]
(dispatch [:update-sync-state error sync])))
(do (.getSyncing
(.-eth web3)
(fn [error sync]
(dispatch [:update-sync-state error sync])))
(s/execute-later #(dispatch [:check-sync]) (s/s->ms 10)))
(s/execute-later #(dispatch [:check-sync]) (s/s->ms 10))))))
(register-handler :initialize-sync-listener