Fixes #1220 Do not let catch escape
This commit is contained in:
parent
01fabc243d
commit
034ff3e413
|
@ -17,9 +17,9 @@
|
||||||
(defn request-access [callback]
|
(defn request-access [callback]
|
||||||
(if platform/android?
|
(if platform/android?
|
||||||
(callback true)
|
(callback true)
|
||||||
(let [result (.checkVideoAuthorizationStatus camera-default)
|
(-> (.checkVideoAuthorizationStatus camera-default)
|
||||||
result (.then result #(callback %))
|
(.then #(callback %))
|
||||||
result (.catch result #(callback false))])))
|
(.catch #(callback false)))))
|
||||||
|
|
||||||
(defn camera [props]
|
(defn camera [props]
|
||||||
(r/create-element camera-default (clj->js (merge {:inverted true} props))))
|
(r/create-element camera-default (clj->js (merge {:inverted true} props))))
|
||||||
|
|
|
@ -19,10 +19,12 @@
|
||||||
|
|
||||||
(defn request-permissions [permissions then else]
|
(defn request-permissions [permissions then else]
|
||||||
(if platform/android?
|
(if platform/android?
|
||||||
(let [permissions (mapv #(get permissions-map %) permissions)
|
(letfn [(else-fn [] (when else (else)))]
|
||||||
result (.requestMultiple permissions-class (clj->js permissions))
|
(let [permissions (mapv #(get permissions-map %) permissions)]
|
||||||
result (.then result #(if (all-granted? (js->clj %))
|
(-> (.requestMultiple permissions-class (clj->js permissions))
|
||||||
(then)
|
(.then #(if (all-granted? (js->clj %))
|
||||||
(when else (else))))
|
(then)
|
||||||
result (.catch result #(else))])
|
(else-fn)))
|
||||||
|
(.catch else-fn))))
|
||||||
|
|
||||||
(then)))
|
(then)))
|
||||||
|
|
|
@ -120,11 +120,17 @@
|
||||||
|
|
||||||
(def image-picker-class (js/require "react-native-image-crop-picker"))
|
(def image-picker-class (js/require "react-native-image-crop-picker"))
|
||||||
|
|
||||||
|
(defn show-access-error [o]
|
||||||
|
(when (= "ERROR_PICKER_UNAUTHORIZED_KEY" (aget o "code")) ; Do not show error when user cancel selection
|
||||||
|
(u/show-popup (i18n/label :t/error)
|
||||||
|
(i18n/label :t/photos-access-error))))
|
||||||
|
|
||||||
(defn show-image-picker [images-fn]
|
(defn show-image-picker [images-fn]
|
||||||
(let [image-picker (.-default image-picker-class)]
|
(let [image-picker (.-default image-picker-class)]
|
||||||
(-> image-picker
|
(-> image-picker
|
||||||
(.openPicker (clj->js {:multiple false}))
|
(.openPicker (clj->js {:multiple false}))
|
||||||
(.then images-fn))))
|
(.then images-fn)
|
||||||
|
(.catch show-access-error))))
|
||||||
|
|
||||||
(def swiper (adapt-class (js/require "react-native-swiper")))
|
(def swiper (adapt-class (js/require "react-native-swiper")))
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
:error "Error"
|
:error "Error"
|
||||||
|
|
||||||
:camera-access-error "To grant the required camera permission, please, go to your system settings and make sure that Status > Camera is selected."
|
:camera-access-error "To grant the required camera permission, please, go to your system settings and make sure that Status > Camera is selected."
|
||||||
|
:photos-access-error "To grant the required photos permission, please, go to your system settings and make sure that Status > Photos is selected."
|
||||||
|
|
||||||
;drawer
|
;drawer
|
||||||
:invite-friends "Invite friends"
|
:invite-friends "Invite friends"
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
(def fs (js/require "react-native-fs"))
|
(def fs (js/require "react-native-fs"))
|
||||||
|
|
||||||
(defn move-file [src dst handler]
|
(defn move-file [src dst handler]
|
||||||
(let [result (.moveFile fs src dst)
|
(-> (.moveFile fs src dst)
|
||||||
result (.then result #(handler nil %))
|
(.then #(handler nil %))
|
||||||
result (.catch result #(handler % nil))]
|
(.catch #(handler % nil))))
|
||||||
result))
|
|
||||||
|
|
||||||
(defn read-file [path encoding on-read on-error]
|
(defn read-file [path encoding on-read on-error]
|
||||||
(-> (.readFile fs path encoding)
|
(-> (.readFile fs path encoding)
|
||||||
|
|
Loading…
Reference in New Issue