Skip to content

Commit

Permalink
Remove redudant navigation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Parveshdhull committed Dec 5, 2024
1 parent 637e9d4 commit cf765f2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 77 deletions.
3 changes: 0 additions & 3 deletions src/status_im/common/enter_seed_phrase/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@
(defn view
[]
(let [{:keys [on-success]} (rf/sub [:get-screen-params])]
(rn/use-unmount
(when-not on-success
#(rf/dispatch [:onboarding/clear-navigated-to-enter-seed-phrase-from-screen])))
[screen
{:title (i18n/label :t/use-recovery-phrase)
:on-success on-success}]))
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
(defn- navigate-to-create-profile
[]
(debounce/throttle-and-dispatch
[:onboarding/navigate-to-create-profile]
[:navigate-to :screen/onboarding.create-profile]
1000))

(defn- navigate-to-sign-in-by-syncing
[]
(rf/dispatch [:syncing/clear-syncing-fallback-flow])
(debounce/throttle-and-dispatch
[:onboarding/navigate-to-sign-in-by-syncing]
[:navigate-to :screen/onboarding.sign-in-intro]
1000))

(defn- show-check-before-syncing
Expand All @@ -38,10 +38,7 @@
(defn- navigate-to-sign-in-by-recovery-phrase
[create-profile?]
(rf/dispatch [:syncing/clear-syncing-fallback-flow])
(rf/dispatch [:onboarding/navigate-to-sign-in-by-seed-phrase
(if create-profile?
:screen/onboarding.new-to-status
:screen/onboarding.sync-or-recover-profile)]))
(rf/dispatch [:navigate-to :screen/onboarding.enter-seed-phrase]))

(defn- option-card-max-height
[window-height]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
:background :blur
:type :grey
:on-press #(rf/dispatch (if syncing-results?
[:navigate-to-within-stack
[:screen/onboarding.enable-notifications
:screen/onboarding.enable-biometrics]]
[:navigate-to :screen/onboarding.enable-notifications]
[:onboarding/create-account-and-login]))
:container-style {:margin-top 12}}
(i18n/label :t/maybe-later)]]))
Expand Down
69 changes: 6 additions & 63 deletions src/status_im/contexts/onboarding/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@
(rf/reg-event-fx
:onboarding/profile-data-set
(fn [{:keys [db]} [onboarding-data]]
(let [navigate-from-screen (get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]
{:db (update db :onboarding/profile merge onboarding-data)
:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.create-profile-password navigate-from-screen]]]]})))
{:db (update db :onboarding/profile merge onboarding-data)
:fx [[:dispatch [:navigate-to :screen/onboarding.create-profile-password]]]}))

(rf/defn enable-biometrics
{:events [:onboarding/enable-biometrics]}
Expand All @@ -40,30 +35,6 @@
{:on-success #(rf/dispatch [:onboarding/biometrics-done])
:on-fail #(rf/dispatch [:onboarding/biometrics-fail %])}]]]})

(rf/reg-event-fx :onboarding/navigate-to-sign-in-by-seed-phrase
(fn [{:keys [db]} [from-screen]]
{:db (assoc db :onboarding/navigated-to-enter-seed-phrase-from-screen from-screen)
:fx [[:dispatch [:navigate-to-within-stack [:screen/onboarding.enter-seed-phrase from-screen]]]]}))

(rf/reg-event-fx
:onboarding/clear-navigated-to-enter-seed-phrase-from-screen
(fn [{:keys [db]}]
{:db (dissoc db :onboarding/navigated-to-enter-seed-phrase-from-screen)}))

(rf/reg-event-fx :onboarding/navigate-to-enable-notifications-from-syncing
(fn [{:keys [db]}]
{:db (dissoc db :onboarding/profile)
:dispatch [:navigate-to-within-stack
[:screen/onboarding.enable-notifications :screen/onboarding.enable-biometrics]]}))

(rf/reg-event-fx :onboarding/navigate-to-enable-notifications
(fn [{:keys [db]}]
{:dispatch [:navigate-to-within-stack
[:screen/onboarding.enable-notifications
(get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]]}))

(rf/defn biometrics-done
{:events [:onboarding/biometrics-done]}
[{:keys [db]}]
Expand All @@ -87,12 +58,7 @@
(= (:syncing/key-uid db)
(get-in db [:onboarding/profile :key-uid])))]
(rf/merge cofx
{:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.preparing-status
(get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]]]
{:fx [[:dispatch [:navigate-to :screen/onboarding.preparing-status]]
(when-not syncing-account-recovered?
[:dispatch [:syncing/clear-syncing-installation-id]])]
:db (-> db
Expand Down Expand Up @@ -121,11 +87,7 @@
(assoc-in [:onboarding/profile :auth-method] constants/auth-method-password))
:fx [[:dispatch
(if biometric-supported-type
[:navigate-to-within-stack
[:screen/onboarding.enable-biometrics
(get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]]
[:navigate-to :screen/onboarding.enable-biometrics]
[:onboarding/create-account-and-login])]]})))

(rf/defn navigate-to-enable-biometrics
Expand Down Expand Up @@ -159,26 +121,7 @@
(assoc-in [:onboarding/profile :key-uid] key-uid)
(assoc-in [:onboarding/profile :color] constants/profile-default-color))
:fx [[:dispatch
[:navigate-to-within-stack
[next-screen
(get db
:onboarding/navigated-to-enter-seed-phrase-from-screen
:screen/onboarding.new-to-status)]]]]})))

(rf/defn navigate-to-create-profile
{:events [:onboarding/navigate-to-create-profile]}
[{:keys [db]}]
;; Restart the flow
{:db (dissoc db :onboarding/profile)
:dispatch [:navigate-to-within-stack
[:screen/onboarding.create-profile :screen/onboarding.new-to-status]]})

(rf/reg-event-fx :onboarding/navigate-to-sign-in-by-syncing
(fn [{:keys [db]}]
;; Restart the flow
{:db (dissoc db :onboarding/profile)
:dispatch [:navigate-to-within-stack
[:screen/onboarding.sign-in-intro :screen/onboarding.sync-or-recover-profile]]}))
[:navigate-to next-screen]]]})))

(rf/reg-event-fx :onboarding/set-auth-method
(fn [{:keys [db]} [auth-method]]
Expand All @@ -203,7 +146,7 @@
(rf/dispatch [:onboarding/set-auth-method auth-method])
(when syncing?
(rf/dispatch
[:onboarding/navigate-to-enable-notifications-from-syncing])))
[:navigate-to :screen/onboarding.enable-notifications])))
:on-error #(log/error "failed to save biometrics"
{:key-uid key-uid
:error %})}))))
Expand Down
3 changes: 1 addition & 2 deletions src/status_im/contexts/onboarding/syncing/progress/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
[]
(rf/dispatch [:syncing/set-syncing-fallback-flow])
(debounce/debounce-and-dispatch
[:onboarding/navigate-to-sign-in-by-seed-phrase :screen/onboarding.sync-or-recover-profile]
500))
[:navigate-to :screen/onboarding.enter-seed-phrase] 500))

(defn- try-again
[logged-in?]
Expand Down

0 comments on commit cf765f2

Please sign in to comment.