Fix null pointer exception on password when migrating to a keykard by disabling the back button in process. (#13977)

This commit is contained in:
Audrius Molis 2022-09-20 19:52:41 +03:00 committed by GitHub
parent 468d827aa2
commit 36c4052039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 17 deletions

View File

@ -279,6 +279,11 @@
[{:keys [db]} k v]
{:db (assoc db k v)})
(fx/defn set-view-id
{:events [:set-view-id]}
[{:keys [db]} view-id]
{:db (assoc db :view-id view-id)})
;;TODO :replace by named events
(fx/defn set-once-event
{:events [:set-once]}

View File

@ -4,6 +4,7 @@
[status-im.utils.utils :as utils]
[status-im.i18n.i18n :as i18n]
[status-im.ethereum.mnemonic :as mnemonic]
[status-im.keycard.common :as common]
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
[status-im.navigation :as navigation]
[status-im.signing.core :as signing.core]
@ -64,4 +65,5 @@
(assoc-in [:keycard :flow] :recovery)
(update :multiaccounts/key-storage dissoc :seed-phrase))
:dismiss-keyboard nil}
(common/listen-to-hardware-back-button)
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))

View File

@ -592,19 +592,6 @@
[{:keys [db]} listeners]
{:db (update-in db [:keycard :listeners] merge listeners)})
(defn onboarding-intro-back-handler
"The back button handler is used to manage device back press.
If the handler returns false, the back button functions as usual (ie. dispatchs GO_BACK event).
If it returns true, the back button becomes inactive.
We want to deactivate the back button when the user comes from key-storage and migration flow."
[]
(-> @re-frame.db/app-db
:keycard
:from-key-storage-and-migration?
boolean))
(fx/defn ui-recovery-phrase-cancel-pressed
{:events [:keycard.ui/recovery-phrase-cancel-pressed]}
[{:keys [db]}]

View File

@ -175,7 +175,9 @@
{:keycard/check-nfc-enabled nil}
(if (= flow :import)
(navigation/navigate-to-cofx :keycard-recovery-intro nil)
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))))
(do
(common/listen-to-hardware-back-button)
(navigation/navigate-to-cofx :keycard-onboarding-intro nil))))))
(fx/defn start-onboarding-flow
{:events [:keycard/start-onboarding-flow]}
@ -183,6 +185,7 @@
(fx/merge cofx
{:db (assoc-in db [:keycard :flow] :create)
:keycard/check-nfc-enabled nil}
(common/listen-to-hardware-back-button)
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))
(fx/defn open-nfc-settings-pressed

View File

@ -86,6 +86,7 @@
(fx/merge cofx
{:db (assoc-in db [:keycard :flow] :recovery)
:keycard/check-nfc-enabled nil}
(common/listen-to-hardware-back-button)
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))
(fx/defn cancel-pressed

View File

@ -2,6 +2,7 @@
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.ethereum.mnemonic :as mnemonic]
[status-im.keycard.common :as common]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
[status-im.multiaccounts.model :as multiaccounts.model]
@ -244,6 +245,7 @@ We don't need to take the exact steps, just set the required state and redirect
(assoc-in [:keycard :converting-account?] (not (get-in db [:multiaccounts/key-storage :reset-db-checked?])))
(dissoc :multiaccounts/key-storage))}
(popover/hide-popover)
(common/listen-to-hardware-back-button)
(navigation/navigate-to-cofx :keycard-onboarding-intro nil)))
(fx/defn handle-delete-multiaccount-error

View File

@ -113,7 +113,7 @@
(defn set-view-id [view-id]
(log/debug "set-view-id" view-id)
(when-let [{:keys [on-focus]} (get views/screens view-id)]
(re-frame/dispatch [:set :view-id view-id])
(re-frame/dispatch [:set-view-id view-id])
(re-frame/dispatch [:screens/on-will-focus view-id])
(when on-focus
(re-frame/dispatch on-focus))))

View File

@ -3,7 +3,6 @@
[quo.previews.main :as quo.preview]
[status-im.add-new.core :as new-chat.events]
[status-im.i18n.i18n :as i18n]
[status-im.keycard.core :as keycard.core]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.screens.about-app.views :as about-app]
[status-im.ui.screens.add-new.new-chat.views :as new-chat]
@ -749,7 +748,10 @@
;KEYCARD
{:name :keycard-onboarding-intro
:insets {:bottom true}
:back-handler keycard.core/onboarding-intro-back-handler
:options {:topBar {:visible false}
:popGesture false
:hardwareBackButton {:dismissModalOnPress false
:popStackOnPress false}}
:component keycard.onboarding/intro}
{:name :keycard-onboarding-puk-code
:insets {:bottom true}