|
365 | 365 | [_]
|
366 | 366 | (status/get-node-config #(re-frame/dispatch [::get-node-config-callback %])))
|
367 | 367 |
|
| 368 | +(rf/defn redirect-to-root |
| 369 | + "Decides which root should be initialised depending on user and app state" |
| 370 | + [{:keys [db] :as cofx}] |
| 371 | + (cond |
| 372 | + (get db :onboarding-2/new-account?) |
| 373 | + {:dispatch [:onboarding-2/finalize-setup]} |
| 374 | + |
| 375 | + (get db :tos/accepted?) |
| 376 | + (rf/merge |
| 377 | + cofx |
| 378 | + (multiaccounts/switch-theme nil :shell-stack) |
| 379 | + (navigation/init-root :shell-stack)) |
| 380 | + |
| 381 | + :else |
| 382 | + {:dispatch [:init-root :tos]})) |
| 383 | + |
368 | 384 | (rf/defn get-settings-callback
|
369 | 385 | {:events [::get-settings-callback]}
|
370 |
| - [{:keys [db] :as cofx} settings] |
| 386 | + [{:keys [db] :as cofx} settings pairing-in-progress?] |
371 | 387 | (let [{:networks/keys [current-network networks]
|
372 | 388 | :as settings}
|
373 | 389 | (data-store.settings/rpc->settings settings)
|
|
397 | 413 | (logging/set-log-level (:log-level multiaccount))
|
398 | 414 | (activity-center/notifications-fetch-pending-contact-requests)
|
399 | 415 | (activity-center/update-seen-state)
|
400 |
| - (activity-center/notifications-fetch-unread-count)))) |
| 416 | + (activity-center/notifications-fetch-unread-count) |
| 417 | + (when-not pairing-in-progress? |
| 418 | + (redirect-to-root))))) |
401 | 419 |
|
402 | 420 | (re-frame/reg-fx
|
403 | 421 | ::open-last-chat
|
|
472 | 490 | keychain/auth-method-biometric
|
473 | 491 | keychain/auth-method-password))))
|
474 | 492 |
|
475 |
| -(defn redirect-to-root |
476 |
| - "Decides which root should be initialised depending on user and app state" |
477 |
| - [db] |
478 |
| - (cond |
479 |
| - (get db :onboarding-2/new-account?) |
480 |
| - (re-frame/dispatch [:onboarding-2/finalize-setup]) |
481 |
| - |
482 |
| - (get db :tos/accepted?) |
483 |
| - (re-frame/dispatch [:init-root :shell-stack]) |
484 |
| - |
485 |
| - :else |
486 |
| - (re-frame/dispatch [:init-root :tos]))) |
487 |
| - |
488 | 493 | (rf/defn login-only-events
|
489 | 494 | [{:keys [db] :as cofx} key-uid password save-password?]
|
490 | 495 | (let [auth-method (:auth-method db)
|
|
497 | 502 | {:db (assoc db :chats/loading? true)
|
498 | 503 | :json-rpc/call
|
499 | 504 | [{:method "settings_getSettings"
|
500 |
| - :on-success #(do (re-frame/dispatch [::get-settings-callback %]) |
501 |
| - (when-not pairing-in-progress? |
502 |
| - (redirect-to-root db)))}]} |
| 505 | + :on-success #(re-frame/dispatch [::get-settings-callback % pairing-in-progress?])}]} |
503 | 506 | (notifications/load-notification-preferences)
|
504 | 507 | (when save-password?
|
505 | 508 | (keychain/save-user-password key-uid password))
|
|
0 commit comments