add .catch for isConnectionExpensive promise; fix ios version
Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
This commit is contained in:
parent
ab084068d3
commit
a521cc7039
|
@ -1,6 +1,7 @@
|
||||||
(ns status-im.network.net-info
|
(ns status-im.network.net-info
|
||||||
(:require [taoensso.timbre :as log]
|
(:require [taoensso.timbre :as log]
|
||||||
[status-im.ui.components.react :as react-components]))
|
[status-im.ui.components.react :as react-components]
|
||||||
|
[status-im.utils.platform :as platform]))
|
||||||
|
|
||||||
(defn is-connected? [callback]
|
(defn is-connected? [callback]
|
||||||
(when react-components/net-info
|
(when react-components/net-info
|
||||||
|
@ -11,10 +12,14 @@
|
||||||
|
|
||||||
(defn- wrap-net-info [callback]
|
(defn- wrap-net-info [callback]
|
||||||
(fn [info-js]
|
(fn [info-js]
|
||||||
(let [info (js->clj info-js :keywordize-keys true)]
|
(let [info (js->clj info-js :keywordize-keys true)
|
||||||
(.then (.isConnectionExpensive react-components/net-info)
|
on-success #(callback {:type (:type info) :expensive? %})]
|
||||||
(fn [expensive?]
|
(if platform/ios?
|
||||||
(callback {:type (:type info) :expensive? expensive?}))))))
|
(on-success false)
|
||||||
|
(.. react-components/net-info
|
||||||
|
isConnectionExpensive
|
||||||
|
(then on-success)
|
||||||
|
(catch (fn [error] (log/warn "isConnectionExpensive: " error))))))))
|
||||||
|
|
||||||
(defn net-info [callback]
|
(defn net-info [callback]
|
||||||
(when react-components/net-info
|
(when react-components/net-info
|
||||||
|
|
Loading…
Reference in New Issue