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 (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])) [react-native.platform :as platform]))
(def permissions-map (def permissions-map
@ -38,3 +38,5 @@
(-> (check (get permissions-map permission)) (-> (check (get permissions-map permission))
(.then #(on-result (not (#{(.-BLOCKED RESULTS) (.-DENIED RESULTS)} %)))) (.then #(on-result (not (#{(.-BLOCKED RESULTS) (.-DENIED RESULTS)} %))))
(.catch #(on-error %)))) (.catch #(on-error %))))
(def open-settings openSettings)

View File

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

View File

@ -138,7 +138,11 @@
(alert/show-popup (alert/show-popup
(i18n/label :t/audio-recorder-error) (i18n/label :t/audio-recorder-error)
(i18n/label (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)}]))}]])) 50)}]))}]]))