add .catch for isConnectionExpensive promise; fix ios version

Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
This commit is contained in:
Roman Volosovskyi 2018-04-11 13:25:38 +01:00 committed by Dmitry Novotochinov
parent ab084068d3
commit a521cc7039
No known key found for this signature in database
GPG Key ID: 267674DCC86628D9
1 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,7 @@
(ns status-im.network.net-info
(: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]
(when react-components/net-info
@ -11,10 +12,14 @@
(defn- wrap-net-info [callback]
(fn [info-js]
(let [info (js->clj info-js :keywordize-keys true)]
(.then (.isConnectionExpensive react-components/net-info)
(fn [expensive?]
(callback {:type (:type info) :expensive? expensive?}))))))
(let [info (js->clj info-js :keywordize-keys true)
on-success #(callback {:type (:type info) :expensive? %})]
(if platform/ios?
(on-success false)
(.. react-components/net-info
isConnectionExpensive
(then on-success)
(catch (fn [error] (log/warn "isConnectionExpensive: " error))))))))
(defn net-info [callback]
(when react-components/net-info