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

[#20638] fix: Scan missing keypair keep scanning after success attempt #20640

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions src/status_im/common/scan_qr_code/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
true)

(defn view
[{:keys [title subtitle validate-fn on-success-scan error-message share-button? import-keypair?]}]
[{:keys [title subtitle validate-fn on-success-scan error-message share-button?]}]
(let [insets (safe-area/get-insets)
qr-code-succeed? (reagent/atom false)
qr-view-finder (reagent/atom {})
Expand Down Expand Up @@ -233,9 +233,7 @@
:set-qr-code-succeeded (fn [value]
(when on-success-scan
(on-success-scan value))
(if import-keypair?
(set-rescan-timeout)
(rf/dispatch [:navigate-back])))
(rf/dispatch [:navigate-back]))
:set-rescan-timeout set-rescan-timeout}])
[rn/view {:style (style/root-container (:top insets))}
[header
Expand Down
8 changes: 3 additions & 5 deletions src/status_im/contexts/settings/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,14 @@
(rf/reg-event-fx :wallet/make-keypairs-accounts-fully-operable make-keypairs-accounts-fully-operable)

(defn connection-string-for-import-keypair
[{:keys [db]} [{:keys [sha3-pwd keypairs-key-uids connection-string on-success]}]]
[{:keys [db]} [{:keys [sha3-pwd keypairs-key-uids connection-string]}]]
(let [key-uid (get-in db [:profile/profile :key-uid])]
{:fx [[:effects.syncing/import-keypairs-keystores
{:key-uid key-uid
:sha3-pwd sha3-pwd
:keypairs-key-uids keypairs-key-uids
:connection-string connection-string
:on-success (fn [key-uids]
(rf/call-continuation on-success)
(rf/dispatch [:wallet/make-keypairs-accounts-fully-operable key-uids]))
:on-fail (fn [error]
(log/error "failed to import missing key pairs with connection string"
Expand All @@ -113,7 +112,7 @@
(rf/reg-event-fx :wallet/connection-string-for-import-keypair connection-string-for-import-keypair)

(defn success-keypair-qr-scan
[_ [connection-string keypairs-key-uids on-import-success]]
[_ [connection-string keypairs-key-uids]]
{:fx [[:dispatch
[:standard-auth/authorize-with-password
{:blur? true
Expand All @@ -125,8 +124,7 @@
[:wallet/connection-string-for-import-keypair
{:connection-string connection-string
:keypairs-key-uids keypairs-key-uids
:sha3-pwd password
:on-success on-import-success}]))}]]]})
:sha3-pwd password}]))}]]]})

(rf/reg-event-fx :wallet/success-keypair-qr-scan success-keypair-qr-scan)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
on-success-scan (rn/use-callback (fn [scanned-text]
(rf/dispatch [:wallet/success-keypair-qr-scan
scanned-text
keypairs-key-uids
[:navigate-back]])
keypairs-key-uids])
[keypairs-key-uids]))]
[scan-qr-code/view
{:title (i18n/label :t/scan-key-pairs-qr-code)
:subtitle (i18n/label :t/find-it-in-setting)
:share-button? false
:import-keypair? true
:validate-fn sync-utils/valid-connection-string?
:error-message (i18n/label :t/invalid-key-pair-qr)
:on-success-scan on-success-scan}]))