Do not navigate-back when selecting from gallery
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
c0d659d008
commit
19fc26c1c2
|
@ -32,10 +32,11 @@
|
|||
|
||||
(handlers/register-handler-fx
|
||||
:extensions/camera-picture-taken
|
||||
(fn [cofx [_ base64 {{:keys [on-success]} :data}]]
|
||||
(fn [cofx [_ data {{:keys [on-success]} :data back? :back?}]]
|
||||
(fx/merge cofx
|
||||
{:dispatch (on-success {:result base64})}
|
||||
(navigation/navigate-back))))
|
||||
{:dispatch (on-success {:result data})}
|
||||
(when back?
|
||||
(navigation/navigate-back)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:extensions/camera-picture
|
||||
|
|
|
@ -12,16 +12,12 @@
|
|||
[status-im.ui.screens.profile.photo-capture.styles :as styles]
|
||||
[status-im.utils.image-processing :as image-processing]))
|
||||
|
||||
;; ensure photo taken or picked are not too big
|
||||
(def max-width 1024)
|
||||
(def max-height 1024)
|
||||
(def default-max-size 1024)
|
||||
|
||||
(defn- process-image-and-finish [path context]
|
||||
(let [on-success (fn [base64]
|
||||
(re-frame/dispatch [:extensions/camera-picture-taken base64 context]))
|
||||
on-error (fn [type error]
|
||||
(re-frame/dispatch [:extensions/camera-error error context]))]
|
||||
(image-processing/img->base64 path on-success on-error max-width max-height)))
|
||||
(let [on-success #(re-frame/dispatch [:extensions/camera-picture-taken % context])
|
||||
on-error #(re-frame/dispatch [:extensions/camera-error %2 context])]
|
||||
(image-processing/img->base64 path on-success on-error default-max-size default-max-size)))
|
||||
|
||||
(defview take-picture []
|
||||
(letsubs [context [:get-screen-params]
|
||||
|
@ -64,6 +60,6 @@
|
|||
{:label (i18n/label :t/image-source-make-photo)
|
||||
:action (fn []
|
||||
(re-frame/dispatch [:request-permissions {:permissions [:camera :write-external-storage]
|
||||
:on-allowed #(re-frame/dispatch [:navigate-to :take-picture context])
|
||||
:on-allowed #(re-frame/dispatch [:navigate-to :take-picture (merge context {:back? true})])
|
||||
:on-denied #(re-frame/dispatch [:extensions/camera-denied context])}]))}]
|
||||
:on-cancel #(re-frame/dispatch [:extensions/camera-cancel context])})
|
||||
:on-cancel #(re-frame/dispatch [:extensions/camera-cancel context])})
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
(defn- http-post [{:keys [url data response-validator success-event-creator failure-event-creator timeout-ms opts]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
on-error #(re-frame/dispatch (failure-event-creator %))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
all-opts (assoc opts
|
||||
:valid-response? response-validator
|
||||
:timeout-ms timeout-ms)]
|
||||
|
@ -75,7 +75,7 @@
|
|||
|
||||
(defn- http-raw-post [{:keys [url body response-validator success-event-creator failure-event-creator timeout-ms opts]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
on-error #(re-frame/dispatch (failure-event-creator %))
|
||||
on-error (when failure-event-creator #(re-frame/dispatch (failure-event-creator %)))
|
||||
all-opts (assoc opts
|
||||
:valid-response? response-validator
|
||||
:timeout-ms timeout-ms)]
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
[status-bar/status-bar {:type :wallet}]
|
||||
[toolbar/toolbar {:style wallet.styles/toolbar}
|
||||
[toolbar/nav-button (actions/back-white #(do (when on-close
|
||||
(on-close (create-payload address)))
|
||||
(re-frame/dispatch (on-close (create-payload address))))
|
||||
(re-frame/dispatch [:update-wallet])
|
||||
(re-frame/dispatch [:navigate-back])))]
|
||||
[toolbar/content-title {:color colors/white}
|
||||
|
@ -78,7 +78,7 @@
|
|||
{:label label
|
||||
:action #(do
|
||||
(when on-open
|
||||
(on-open address))
|
||||
(re-frame/dispatch (on-open address)))
|
||||
(re-frame/dispatch [:navigate-to :wallet-settings-hook m]))})
|
||||
|
||||
(defview toolbar-view []
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
(ns status-im.utils.image-processing
|
||||
(:require [goog.object :as object]
|
||||
[status-im.utils.fs :refer [read-file]]
|
||||
[taoensso.timbre :as log]
|
||||
[clojure.string :as str]
|
||||
[status-im.utils.fs :as fs]
|
||||
[status-im.react-native.js-dependencies :as rn-dependencies]))
|
||||
|
||||
(defn- resize [path max-width max-height on-resize on-error]
|
||||
|
@ -14,16 +12,12 @@
|
|||
(.catch on-error))))
|
||||
|
||||
(defn- image-base64-encode [path on-success on-error]
|
||||
(let [on-error (fn [error]
|
||||
(on-error :base64 error))]
|
||||
(read-file path "base64" on-success on-error)))
|
||||
(fs/read-file path "base64" on-success #(on-error :base64 %)))
|
||||
|
||||
(defn img->base64 [path on-success on-error max-width max-height]
|
||||
(let [on-resized (fn [image]
|
||||
(let [path (object/get image "path")]
|
||||
(log/debug "Resized: " path)
|
||||
(image-base64-encode path on-success on-error)))
|
||||
on-error (fn [error]
|
||||
(log/debug "Resized error: " error)
|
||||
(on-error :resize error))]
|
||||
(resize path max-width max-height on-resized on-error)))
|
||||
|
|
Loading…
Reference in New Issue