From b33a238f45f8072c63d26503a8f8b3230fef946f Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 24 Jul 2019 17:04:58 +0800 Subject: [PATCH] feat(neuron-ui): add check on current wallet id on leaving settings view --- packages/neuron-ui/src/components/Settings/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/neuron-ui/src/components/Settings/index.tsx b/packages/neuron-ui/src/components/Settings/index.tsx index 706086e1b6..fa6c20346d 100644 --- a/packages/neuron-ui/src/components/Settings/index.tsx +++ b/packages/neuron-ui/src/components/Settings/index.tsx @@ -9,6 +9,7 @@ import { StateWithDispatch } from 'states/stateProvider/reducer' import GeneralSetting from 'components/GeneralSetting' import Wallets from 'components/WalletSetting' import NetworkSetting from 'components/NetworkSetting' +import { WalletWizardPath } from 'components/WalletWizard' import { Routes } from 'utils/const' @@ -46,15 +47,16 @@ const Settings = ({ ...neuronWalletState }: React.PropsWithoutRef) => { const [t] = useTranslation() - const goBack = useCallback(() => { - history.goBack() - }, [history]) + const { id } = neuronWalletState.wallet + const onLeave = useCallback(() => { + return id ? history.push(Routes.Overview) : history.push(`${Routes.WalletWizard}${WalletWizardPath.Welcome}`) + }, [id, history]) return ( - +