[Fix] QR scanner scanning QR when user moved to next screen (#16012)

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
Mohamed Javid 2023-05-30 23:58:57 +08:00 committed by GitHub
parent 9a4f8f97b9
commit 863dac6e6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 14 deletions

View File

@ -31,7 +31,9 @@
(defn try-again-button (defn try-again-button
[profile-color] [profile-color]
[quo/button [quo/button
{:on-press #(rf/dispatch [:navigate-back]) {:on-press (fn []
(rf/dispatch [:syncing/clear-states])
(rf/dispatch [:navigate-back]))
:accessibility-label :try-again-later-button :accessibility-label :try-again-later-button
:override-background-color (colors/custom-color profile-color 60) :override-background-color (colors/custom-color profile-color 60)
:style style/try-again-button} :style style/try-again-button}

View File

@ -24,6 +24,11 @@
[{:keys [db]} role] [{:keys [db]} role]
{:db (assoc-in db [:syncing :role] role)}) {:db (assoc-in db [:syncing :role] role)})
(rf/defn local-pairing-clear-states
{:events [:syncing/clear-states]}
[{:keys [db]} role]
{:db (dissoc db :syncing)})
(defn- get-default-node-config (defn- get-default-node-config
[installation-id] [installation-id]
(let [db {:networks/current-network config/default-network (let [db {:networks/current-network config/default-network

View File

@ -201,19 +201,23 @@
:text (i18n/label :text (i18n/label
:t/camera-permission-denied)}])}]))] :t/camera-permission-denied)}])}]))]
(fn [] (fn []
(let [camera-ref (atom nil) (let [camera-ref (atom nil)
read-qr-once? (atom false) read-qr-once? (atom false)
on-read-code (fn [data] ;; The below check is to prevent scanning of any QR code
(when-not @read-qr-once? ;; when the user is in syncing progress screen
(reset! read-qr-once? true) user-in-syncing-progress-screen? (= (rf/sub [:view-id]) :syncing-progress)
(js/setTimeout (fn [] on-read-code (fn [data]
(reset! read-qr-once? false)) (when (and (not @read-qr-once?)
3000) (not user-in-syncing-progress-screen?))
(check-qr-code-data data))) (reset! read-qr-once? true)
scan-qr-code-tab? (= @active-tab 1) (js/setTimeout (fn []
show-camera? (and scan-qr-code-tab? @camera-permission-granted?) (reset! read-qr-once? false))
show-holes? (and show-camera? 3000)
(boolean (not-empty @qr-view-finder)))] (check-qr-code-data data)))
scan-qr-code-tab? (= @active-tab 1)
show-camera? (and scan-qr-code-tab? @camera-permission-granted?)
show-holes? (and show-camera?
(boolean (not-empty @qr-view-finder)))]
(rn/use-effect (rn/use-effect
(fn [] (fn []
(when-not @camera-permission-granted? (when-not @camera-permission-granted?