From 60a8b944d93d8abe4f4200100885cb0c364665ef Mon Sep 17 00:00:00 2001 From: Brian Sztamfater Date: Mon, 26 Jun 2023 10:35:13 -0300 Subject: [PATCH] fix: send user to settings if audio permission is rejected (#16049) --- src/react_native/permissions.cljs | 4 ++- src/status_im2/common/alert/events.cljs | 28 ++++++++++++------- .../contexts/chat/composer/actions/view.cljs | 6 +++- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/react_native/permissions.cljs b/src/react_native/permissions.cljs index 24794103f0..289d356fe9 100644 --- a/src/react_native/permissions.cljs +++ b/src/react_native/permissions.cljs @@ -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) diff --git a/src/status_im2/common/alert/events.cljs b/src/status_im2/common/alert/events.cljs index bb0906843a..ae48e44dd5 100644 --- a/src/status_im2/common/alert/events.cljs +++ b/src/status_im2/common/alert/events.cljs @@ -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 diff --git a/src/status_im2/contexts/chat/composer/actions/view.cljs b/src/status_im2/contexts/chat/composer/actions/view.cljs index e1336339d4..cf53b25daf 100644 --- a/src/status_im2/contexts/chat/composer/actions/view.cljs +++ b/src/status_im2/contexts/chat/composer/actions/view.cljs @@ -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)}]))}]]))