@@ -25,7 +25,11 @@ import { lstrings } from '../locales/strings'
2525import type { WalletCreateItem } from '../selectors/getCreateWalletList'
2626import { config } from '../theme/appConfig'
2727import type { Dispatch , GetState , ThunkAction } from '../types/reduxTypes'
28- import type { EdgeAppSceneProps , NavigationBase } from '../types/routerTypes'
28+ import type {
29+ EdgeAppSceneProps ,
30+ NavigationBase ,
31+ RootSceneProps
32+ } from '../types/routerTypes'
2933import { currencyCodesToEdgeAssets } from '../util/CurrencyInfoHelpers'
3034import { logActivity } from '../util/logger'
3135import { logEvent , trackError } from '../util/tracking'
@@ -52,12 +56,11 @@ const PER_WALLET_TIMEOUT = 5000
5256const MIN_CREATE_WALLET_TIMEOUT = 20000
5357
5458export function initializeAccount (
55- navigation : NavigationBase ,
59+ navigation : RootSceneProps < 'login' > [ 'navigation' ] ,
5660 account : EdgeAccount
5761) : ThunkAction < Promise < void > > {
5862 return async ( dispatch , getState ) => {
5963 const { newAccount } = account
60- const rootNavigation = getRootNavigation ( navigation )
6164
6265 // Load all settings upfront so we can navigate immediately after LOGIN
6366 const [ syncedSettings , localSettings ] = await Promise . all ( [
@@ -80,15 +83,15 @@ export function initializeAccount(
8083 // Navigate immediately - all settings are now in Redux
8184 if ( newAccount ) {
8285 await navigateToNewAccountFlow (
83- rootNavigation ,
86+ navigation ,
8487 account ,
8588 syncedSettings ,
8689 referralPromise ,
8790 dispatch ,
8891 getState
8992 )
9093 } else {
91- navigateToExistingAccountHome ( rootNavigation , referralPromise )
94+ navigateToExistingAccountHome ( navigation , referralPromise )
9295 }
9396
9497 performance . mark ( 'loginEnd' , { detail : { isNewAccount : newAccount } } )
@@ -143,6 +146,9 @@ export function initializeAccount(
143146
144147 // Check for security alerts:
145148 if ( hasSecurityAlerts ( account ) ) {
149+ // This is not the normal security alerts scene!
150+ // Since we only have access to the root navigator,
151+ // this scene exists as a peer of the main app:
146152 navigation . push ( 'securityAlerts' )
147153 hideSurvey = true
148154 }
@@ -208,7 +214,7 @@ export function initializeAccount(
208214 * Navigate to wallet creation flow for new accounts.
209215 */
210216async function navigateToNewAccountFlow (
211- rootNavigation : NavigationBase ,
217+ navigation : RootSceneProps < 'login' > [ 'navigation' ] ,
212218 account : EdgeAccount ,
213219 syncedSettings : SyncedAccountSettings ,
214220 referralPromise : Promise < void > ,
@@ -279,7 +285,7 @@ async function navigateToNewAccountFlow(
279285 )
280286 }
281287
282- rootNavigation . replace ( 'edgeApp' , {
288+ navigation . replace ( 'edgeApp' , {
283289 screen : 'edgeAppStack' ,
284290 params : {
285291 screen : 'createWalletSelectCryptoNewAccount' ,
@@ -296,11 +302,11 @@ async function navigateToNewAccountFlow(
296302 * Navigate to home screen for existing accounts.
297303 */
298304function navigateToExistingAccountHome (
299- rootNavigation : NavigationBase ,
305+ navigation : RootSceneProps < 'login' > [ 'navigation' ] ,
300306 referralPromise : Promise < void >
301307) : void {
302308 const { defaultScreen } = getDeviceSettings ( )
303- rootNavigation . replace ( 'edgeApp' , {
309+ navigation . replace ( 'edgeApp' , {
304310 screen : 'edgeAppStack' ,
305311 params : {
306312 screen : 'edgeTabs' ,
0 commit comments