Fix network status change logic and #8951
This commit is contained in:
parent
eb00df147d
commit
33af176246
|
@ -7,12 +7,16 @@
|
|||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.chaos-mode.core :as chaos-mode]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.screens.mobile-network-settings.events :as mobile-network]))
|
||||
[status-im.ui.screens.mobile-network-settings.events :as mobile-network]
|
||||
[status-im.wallet.core :as wallet]))
|
||||
|
||||
(fx/defn change-network-status
|
||||
[{:keys [db] :as cofx} is-connected?]
|
||||
(fx/merge cofx
|
||||
{:db (assoc db :network-status (if is-connected? :online :offline))}
|
||||
(when is-connected?
|
||||
(if-not (= (count (get-in db [:wallet :accounts])) (count (get-in db [:multiaccount :accounts])))
|
||||
(wallet/update-balances nil)))
|
||||
(mailserver/network-connection-status-changed is-connected?)))
|
||||
|
||||
(fx/defn change-network-type
|
||||
|
@ -26,12 +30,13 @@
|
|||
|
||||
(fx/defn handle-network-info-change
|
||||
{:events [::network-info-changed]}
|
||||
[{:keys [db] :as cofx} {:keys [is-connected type details] :as state}]
|
||||
[{:keys [db] :as cofx} {:keys [isConnected type details] :as state}]
|
||||
(let [old-network-status (:network-status db)
|
||||
old-network-type (:network/type db)]
|
||||
old-network-type (:network/type db)
|
||||
connectivity-status (if isConnected :online :offline)]
|
||||
(fx/merge cofx
|
||||
(when-not (= is-connected old-network-status)
|
||||
(change-network-status is-connected))
|
||||
(when-not (= connectivity-status old-network-status)
|
||||
(change-network-status isConnected))
|
||||
(when-not (= type old-network-type)
|
||||
(change-network-type old-network-type type (:is-connection-expensive details))))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue