Skip to content

Commit

Permalink
fix unable to open add-new-contact screen if hardware button is press…
Browse files Browse the repository at this point in the history
…ed while qr scanner is open (#18296)
  • Loading branch information
Parveshdhull authored Jan 3, 2024
1 parent f2c69ab commit fc591f3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/status_im/common/scan_qr_code/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
#(reset! camera-permission-granted? %)
#(reset! camera-permission-granted? false)))))
(permissions/permission-granted?
:camera
#(reset! camera-permission-granted? %)
#(reset! camera-permission-granted? false)))
#(rn/hw-back-remove-listener navigate-back-handler)))
[:<>
[rn/view {:style style/background}]
(when camera-ready-to-scan?
Expand Down

0 comments on commit fc591f3

Please sign in to comment.