From ed63fe42d09811b93457942760715c38b03ad644 Mon Sep 17 00:00:00 2001 From: Tan Le Date: Fri, 14 Jun 2024 10:22:53 +0700 Subject: [PATCH] fix: use pure navigateBack instead of fixed route to unexpected behavior --- apps/wallet/src/stacks/Home/index.tsx | 8 ++------ apps/wallet/src/stacks/Setting/index.tsx | 10 ++++++---- apps/wallet/src/stacks/Setting/utils.ts | 10 ---------- apps/wallet/src/stacks/Setting/utils.web.ts | 13 ------------- 4 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 apps/wallet/src/stacks/Setting/utils.ts delete mode 100644 apps/wallet/src/stacks/Setting/utils.web.ts diff --git a/apps/wallet/src/stacks/Home/index.tsx b/apps/wallet/src/stacks/Home/index.tsx index 321613d1c..d24319092 100644 --- a/apps/wallet/src/stacks/Home/index.tsx +++ b/apps/wallet/src/stacks/Home/index.tsx @@ -7,7 +7,7 @@ import HistoryScreen from 'screens/Dashboard/History'; import ProfileScreen from 'screens/Dashboard/Home'; import { noHeaderNavigation } from 'utils/constants'; import type { DashboardParamList, HomeParamList } from 'utils/navigation'; -import { navigate } from 'utils/navigation'; +import { navigateBack } from 'utils/navigation'; type Props = StackScreenProps; @@ -22,11 +22,7 @@ export const HomeStack: FC = () => { const ManagedHistoryScreen = useMemo(() => { return withStackContainer(HistoryScreen, { title: 'Transaction History', - goBack: () => - navigate('Dashboard', { - screen: 'Home', - params: { screen: 'Default' }, - }), + goBack: navigateBack, }); }, []); diff --git a/apps/wallet/src/stacks/Setting/index.tsx b/apps/wallet/src/stacks/Setting/index.tsx index 672723a5c..15fd3f352 100644 --- a/apps/wallet/src/stacks/Setting/index.tsx +++ b/apps/wallet/src/stacks/Setting/index.tsx @@ -6,11 +6,13 @@ import { withStackContainer } from 'components/StackContainer'; import ReferralScreen from 'screens/Dashboard/Referral'; import SettingScreen from 'screens/Dashboard/Setting'; import { appState } from 'state/app'; -import type { DashboardParamList, SettingParamList } from 'utils/navigation'; +import { + type DashboardParamList, + navigateBack, + type SettingParamList, +} from 'utils/navigation'; import { useSnapshot } from 'valtio'; -import { handleGoBackFromReferralScreen } from './utils'; - type Props = StackScreenProps; const Stack = createStackNavigator(); @@ -28,7 +30,7 @@ export const SettingStack: FC = () => { return withStackContainer(ReferralScreen, { title: 'Referral', noBottomTabs: !navigationDisplay.isBottomTabActive, - goBack: handleGoBackFromReferralScreen, + goBack: navigateBack, }); }, []); diff --git a/apps/wallet/src/stacks/Setting/utils.ts b/apps/wallet/src/stacks/Setting/utils.ts deleted file mode 100644 index f034b2ccd..000000000 --- a/apps/wallet/src/stacks/Setting/utils.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { navigate } from 'utils/navigation'; - -export const handleGoBackFromReferralScreen = () => { - navigate('Dashboard', { - screen: 'Setting', - params: { - screen: 'Default', - }, - }); -}; diff --git a/apps/wallet/src/stacks/Setting/utils.web.ts b/apps/wallet/src/stacks/Setting/utils.web.ts deleted file mode 100644 index e5abbb3f9..000000000 --- a/apps/wallet/src/stacks/Setting/utils.web.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { navigate } from 'utils/navigation'; - -export const handleGoBackFromReferralScreen = () => { - navigate('Dashboard', { - screen: 'Explore', - params: { - screen: 'Profile', - params: { - screen: 'Setting', - }, - }, - }); -};