fix: send user to settings if audio permission is rejected (#16049)

This commit is contained in:
Brian Sztamfater 2023-06-26 10:35:13 -03:00 committed by GitHub
parent 437cfa9a77
commit 60a8b944d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 12 deletions

View File

@ -1,5 +1,5 @@
(ns react-native.permissions
(:require ["react-native-permissions" :refer (check requestMultiple PERMISSIONS RESULTS)]
(:require ["react-native-permissions" :refer (check openSettings requestMultiple PERMISSIONS RESULTS)]
[react-native.platform :as platform]))
(def permissions-map
@ -38,3 +38,5 @@
(-> (check (get permissions-map permission))
(.then #(on-result (not (#{(.-BLOCKED RESULTS) (.-DENIED RESULTS)} %))))
(.catch #(on-error %))))
(def open-settings openSettings)

View File

@ -5,17 +5,25 @@
(defn show-popup
([title content]
(show-popup title content nil))
(show-popup title content nil nil))
([title content on-dismiss]
(rn/alert
title
content
(vector (merge {:text "OK"
:style "cancel"
:accessibility-label :cancel-button}
(when on-dismiss {:onPress on-dismiss})))
(when on-dismiss
{:cancelable false}))))
(show-popup title content on-dismiss nil))
([title content on-dismiss action-button]
(let [dismiss-button
(merge {:text "OK"
:style "cancel"
:accessibility-label :cancel-button}
(when on-dismiss {:onPress on-dismiss}))]
(rn/alert
title
content
(if action-button
(vector
action-button
dismiss-button)
dismiss-button)
(when on-dismiss
{:cancelable false})))))
(re-frame/reg-fx
:utils/show-popup

View File

@ -138,7 +138,11 @@
(alert/show-popup
(i18n/label :t/audio-recorder-error)
(i18n/label
:t/audio-recorder-permissions-error)))
:t/audio-recorder-permissions-error)
nil
{:text (i18n/label :t/settings)
:accessibility-label :settings-button
:onPress (fn [] (permissions/open-settings))}))
50)}]))}]]))