[wallet] Watch txs history while app is in the background (Android only)
This commit is contained in:
parent
8748280279
commit
c33e2be76b
|
@ -1191,19 +1191,16 @@
|
||||||
(dissoc :app-in-background-since)
|
(dissoc :app-in-background-since)
|
||||||
(assoc :app-active-since now))}
|
(assoc :app-active-since now))}
|
||||||
(mailserver/process-next-messages-request)
|
(mailserver/process-next-messages-request)
|
||||||
(wallet/restart-wallet-service {:force-start? true})
|
(wallet/restart-wallet-service-after-background app-in-background-since)
|
||||||
#(when requires-bio-auth
|
#(when requires-bio-auth
|
||||||
(biometric/authenticate % on-biometric-auth-result authentication-options)))))
|
(biometric/authenticate % on-biometric-auth-result authentication-options)))))
|
||||||
|
|
||||||
(fx/defn on-going-in-background
|
(fx/defn on-going-in-background
|
||||||
[{:keys [db now] :as cofx}]
|
[{:keys [db now] :as cofx}]
|
||||||
(fx/merge
|
{:db (-> db
|
||||||
cofx
|
(dissoc :app-active-since)
|
||||||
{:db (-> db
|
(assoc :app-in-background-since now))
|
||||||
(dissoc :app-active-since)
|
:dispatch-n [[:audio-recorder/on-background] [:audio-message/on-background]]})
|
||||||
(assoc :app-in-background-since now))
|
|
||||||
:dispatch-n [[:audio-recorder/on-background] [:audio-message/on-background]]}
|
|
||||||
(wallet/clear-timeouts)))
|
|
||||||
|
|
||||||
(defn app-state-change [state {:keys [db] :as cofx}]
|
(defn app-state-change [state {:keys [db] :as cofx}]
|
||||||
(let [app-coming-from-background? (= state "active")
|
(let [app-coming-from-background? (= state "active")
|
||||||
|
|
|
@ -269,7 +269,8 @@
|
||||||
|
|
||||||
(defn start-wallet [watch-new-blocks?]
|
(defn start-wallet [watch-new-blocks?]
|
||||||
(log/debug "[native-module] start-wallet" watch-new-blocks?)
|
(log/debug "[native-module] start-wallet" watch-new-blocks?)
|
||||||
(.startWallet ^js (status) watch-new-blocks?))
|
(when (status)
|
||||||
|
(.startWallet ^js (status) watch-new-blocks?)))
|
||||||
|
|
||||||
(defn stop-local-notifications []
|
(defn stop-local-notifications []
|
||||||
(log/debug "[native-module] stop-local-notifications")
|
(log/debug "[native-module] stop-local-notifications")
|
||||||
|
|
|
@ -13,8 +13,12 @@
|
||||||
(defn now []
|
(defn now []
|
||||||
(t/now))
|
(t/now))
|
||||||
|
|
||||||
(def hour (* 1000 60 60))
|
(def one-second 1000)
|
||||||
(def day (* hour 24))
|
(def minute (* 60 one-second))
|
||||||
|
(defn minutes [m]
|
||||||
|
(* m minute))
|
||||||
|
(def hour (* 60 minute))
|
||||||
|
(def day (* 24 hour))
|
||||||
(def week (* 7 day))
|
(def week (* 7 day))
|
||||||
(def units [{:name :t/datetime-second-short :limit 60 :in-second 1}
|
(def units [{:name :t/datetime-second-short :limit 60 :in-second 1}
|
||||||
{:name :t/datetime-minute-short :limit 3600 :in-second 60}
|
{:name :t/datetime-minute-short :limit 3600 :in-second 60}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
[status-im.wallet.utils :as wallet.utils]
|
[status-im.wallet.utils :as wallet.utils]
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.ui.screens.mobile-network-settings.utils :as mobile-network-utils]
|
[status-im.ui.screens.mobile-network-settings.utils :as mobile-network-utils]
|
||||||
|
[status-im.utils.datetime :as datetime]
|
||||||
status-im.wallet.recipient.core))
|
status-im.wallet.recipient.core))
|
||||||
|
|
||||||
(defn get-balance
|
(defn get-balance
|
||||||
|
@ -543,8 +544,8 @@
|
||||||
(log/info "start-wallet fx" watch-new-blocks?)
|
(log/info "start-wallet fx" watch-new-blocks?)
|
||||||
(status/start-wallet watch-new-blocks?)))
|
(status/start-wallet watch-new-blocks?)))
|
||||||
|
|
||||||
(def ms-10-min (* 10 60 1000))
|
(def ms-10-min (datetime/minutes 10))
|
||||||
(def ms-20-min (* 20 60 1000))
|
(def ms-20-min (datetime/minutes 20))
|
||||||
|
|
||||||
(fx/defn stop-wallet
|
(fx/defn stop-wallet
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
|
@ -595,6 +596,16 @@
|
||||||
(start-wallet cofx (boolean (or watch-new-blocks? watching-txs?)))
|
(start-wallet cofx (boolean (or watch-new-blocks? watching-txs?)))
|
||||||
(stop-wallet cofx)))))
|
(stop-wallet cofx)))))
|
||||||
|
|
||||||
|
(def background-cooldown-time (datetime/minutes 3))
|
||||||
|
|
||||||
|
(fx/defn restart-wallet-service-after-background
|
||||||
|
[{:keys [now] :as cofx} background-time]
|
||||||
|
(when (> (- now background-time)
|
||||||
|
background-cooldown-time)
|
||||||
|
(restart-wallet-service
|
||||||
|
cofx
|
||||||
|
{:force-start? true})))
|
||||||
|
|
||||||
(fx/defn restart-wallet-service-default
|
(fx/defn restart-wallet-service-default
|
||||||
[cofx]
|
[cofx]
|
||||||
(restart-wallet-service cofx nil))
|
(restart-wallet-service cofx nil))
|
||||||
|
|
Loading…
Reference in New Issue