From a06a745e8b8a823a67cd0c54a66e44c3a5e073d7 Mon Sep 17 00:00:00 2001 From: stackchain <30806844+stackchain@users.noreply.github.com> Date: Tue, 18 Jan 2022 18:26:10 -0500 Subject: [PATCH] [fix] Return to main nav --- src/Settings/WalletSettingsScreen.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Settings/WalletSettingsScreen.tsx b/src/Settings/WalletSettingsScreen.tsx index 894f7abd10..d3251413d8 100644 --- a/src/Settings/WalletSettingsScreen.tsx +++ b/src/Settings/WalletSettingsScreen.tsx @@ -1,4 +1,5 @@ import {useNavigation} from '@react-navigation/native' +import {CommonActions} from '@react-navigation/routers' import React from 'react' import type {MessageDescriptor} from 'react-intl' import {defineMessages, useIntl} from 'react-intl' @@ -15,7 +16,7 @@ import { SettingsSection, } from '../../legacy/components/Settings/SettingsItems' import {StatusBar} from '../../legacy/components/UiKit' -import {isByron, isHaskellShelley} from '../../legacy/config/config' +import {CONFIG, isByron, isHaskellShelley} from '../../legacy/config/config' import {getNetworkConfigById} from '../../legacy/config/networks' import type {NetworkId, WalletImplementationId} from '../../legacy/config/types' import walletManager from '../../legacy/crypto/walletManager' @@ -248,6 +249,8 @@ const LogoutButton = () => { return } +const rootRoute = __DEV__ && CONFIG.DEBUG.START_WITH_INDEX_SCREEN ? 'screens-index' : 'app-root' + const useResync = (options?: UseMutationOptions) => { const intl = useIntl() const navigation = useNavigation() @@ -260,8 +263,13 @@ const useResync = (options?: UseMutationOptions) => { resyncWithConfirmation: async () => { const selection = await showConfirmationDialog(confirmationMessages.resync, intl) if (selection === DIALOG_BUTTONS.YES) { - navigation.goBack() - navigation.goBack() + navigation.dispatch( + CommonActions.reset({ + index: 0, + routes: [{name: rootRoute}], + }), + ) + navigation.navigate(rootRoute) setTimeout(() => mutation.mutate(), 1000) // wait for navigation to finish } },