Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sometimes add contact screen is closed by itself after scanning QR code #18101

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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