Skip to content

Commit

Permalink
fix sometimes add contact screen is closed by itself after scanning Q…
Browse files Browse the repository at this point in the history
…R code
  • Loading branch information
Parveshdhull committed Dec 6, 2023
1 parent 390bbdb commit 6291db9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/status_im2/common/scan_qr_code/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,12 @@
[camera-permission-view]))

(defn- check-qr-code-and-navigate
[{:keys [event error-message validate-fn on-success-scan on-failed-scan]}]
[{:keys [event error-message validate-fn on-success-scan on-failed-scan scan-code?]}]
(let [scanned-value (string/trim (oops/oget event "nativeEvent.codeStringValue"))
validated? (if validate-fn (validate-fn scanned-value) true)]
;; Note - camera-kit keeps scanning until the screen is dismissed,
;; so disable scanning to make sure the on-read-code doesn't get executed multiple times
(reset! scan-code? false)
(if validated?
(on-success-scan scanned-value)
(do
Expand All @@ -155,8 +158,9 @@
:zoom-mode :off
:torch-mode torch-mode
:scan-barcode true
:on-read-code #(when scan-code?
:on-read-code #(when @scan-code?
(check-qr-code-and-navigate {:event %
:scan-code? scan-code?
:validate-fn validate-fn
:error-message error-message
:on-success-scan set-qr-code-succeeded
Expand Down Expand Up @@ -209,7 +213,7 @@
[render-camera
{:torch-mode torch-mode
:qr-view-finder @qr-view-finder
:scan-code? @scan-code?
:scan-code? scan-code?
:error-message error-message
:validate-fn validate-fn
:set-qr-code-succeeded (fn [value]
Expand Down

0 comments on commit 6291db9

Please sign in to comment.