fix unable to open add-new-contact screen if hardware button is pressed while qr scanner is open (#18296)

This commit is contained in:
Parvesh Monu 2024-01-03 18:24:58 +05:30 committed by GitHub
parent f2c69ab9a8
commit fc591f303c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -180,6 +180,11 @@
app-state-listener (.addEventListener rn/app-state "change" set-torch-off-fn)]
#(.remove app-state-listener)))
(defn- navigate-back-handler
[]
(rf/dispatch [:navigate-back])
true)
(defn f-view-internal
[{:keys [title subtitle validate-fn on-success-scan error-message]}]
(let [insets (safe-area/get-insets)
@ -197,15 +202,16 @@
(boolean (not-empty @qr-view-finder)))
camera-ready-to-scan? (and show-camera?
(not @qr-code-succeed?))]
(rn/use-effect
#(set-listener-torch-off-on-app-inactive torch?))
(rn/use-effect
(fn []
(rn/hw-back-add-listener navigate-back-handler)
(set-listener-torch-off-on-app-inactive torch?)
(when-not @camera-permission-granted?
(permissions/permission-granted? :camera
(permissions/permission-granted?
:camera
#(reset! camera-permission-granted? %)
#(reset! camera-permission-granted? false)))))
#(reset! camera-permission-granted? false)))
#(rn/hw-back-remove-listener navigate-back-handler)))
[:<>
[rn/view {:style style/background}]
(when camera-ready-to-scan?