[#5047] Do not show QR code scanner when camera permissions has not been granted
This commit is contained in:
parent
b6a68e79c7
commit
229c64f002
|
@ -14,7 +14,7 @@
|
|||
(defn all-granted? [permissions]
|
||||
(let [permission-vals (distinct (vals permissions))]
|
||||
(and (= (count permission-vals) 1)
|
||||
(not= (first permission-vals) "denied"))))
|
||||
(not (#{"denied" "never_ask_again"} (first permission-vals))))))
|
||||
|
||||
(defn request-permissions [{:keys [permissions on-allowed on-denied]
|
||||
:or {on-allowed #()
|
||||
|
|
|
@ -53,8 +53,11 @@
|
|||
:action (fn []
|
||||
(re-frame/dispatch [:request-permissions {:permissions [:camera :write-external-storage]
|
||||
:on-allowed #(re-frame/dispatch [:navigate-to :profile-photo-capture])
|
||||
:on-denied #(utils/show-popup (i18n/label :t/error)
|
||||
(i18n/label :t/camera-access-error))}]))}])
|
||||
:on-denied (fn []
|
||||
(utils/set-timeout
|
||||
#(utils/show-popup (i18n/label :t/error)
|
||||
(i18n/label :t/camera-access-error))
|
||||
50))}]))}])
|
||||
|
||||
(defn qr-viewer-toolbar [label value]
|
||||
[toolbar/toolbar {}
|
||||
|
|
|
@ -8,11 +8,14 @@
|
|||
(handlers/register-handler-fx
|
||||
:scan-qr-code
|
||||
(fn [{:keys [db]} [_ identifier handler]]
|
||||
{:db (assoc-in db [:qr-codes identifier] handler)
|
||||
{:db (assoc-in db [:qr-codes identifier] handler)
|
||||
:request-permissions-fx {:permissions [:camera]
|
||||
:on-allowed #(re-frame/dispatch [:navigate-to :qr-scanner {:current-qr-context identifier}])
|
||||
:on-denied #(utils/show-popup (i18n/label :t/error)
|
||||
(i18n/label :t/camera-access-error))}}))
|
||||
:on-denied (fn []
|
||||
(utils/set-timeout
|
||||
#(utils/show-popup (i18n/label :t/error)
|
||||
(i18n/label :t/camera-access-error))
|
||||
50))}}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:clear-qr-code
|
||||
|
|
|
@ -163,8 +163,11 @@
|
|||
(defn- request-camera-permissions []
|
||||
(re-frame/dispatch [:request-permissions {:permissions [:camera]
|
||||
:on-allowed #(re-frame/dispatch [:navigate-to :recipient-qr-code])
|
||||
:on-denied #(utils/show-popup (i18n/label :t/error)
|
||||
(i18n/label :t/camera-access-error))}]))
|
||||
:on-denied #(utils/set-timeout
|
||||
(fn []
|
||||
(utils/show-popup (i18n/label :t/error)
|
||||
(i18n/label :t/camera-access-error)))
|
||||
50)}]))
|
||||
|
||||
(defn- on-choose-recipient [contact-only?]
|
||||
(list-selection/show {:title (i18n/label :t/wallet-choose-recipient)
|
||||
|
|
Loading…
Reference in New Issue