From fe3390e77685ad3ff9a5259425f3b89b90b52f97 Mon Sep 17 00:00:00 2001 From: gregs Date: Wed, 16 Oct 2024 03:52:54 -0300 Subject: [PATCH 1/3] complete swap navigate back to previous screen --- .../screens/Swap/providers/swap-provider.tsx | 11 +++++++++-- src/navigation/Navigation.js | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/__swaps__/screens/Swap/providers/swap-provider.tsx b/src/__swaps__/screens/Swap/providers/swap-provider.tsx index bbc534d55cc..ad2761e9ab0 100644 --- a/src/__swaps__/screens/Swap/providers/swap-provider.tsx +++ b/src/__swaps__/screens/Swap/providers/swap-provider.tsx @@ -329,14 +329,21 @@ export const SwapProvider = ({ children }: SwapProviderProps) => { clearCustomGasSettings(chainId); NotificationManager?.postNotification('rapCompleted'); performanceTracking.getState().executeFn({ - fn: Navigation.handleAction, + fn: () => { + const { routes, index } = Navigation.getState(); + if (routes[index - 1].name === 'ExpandedAssetSheet') { + Navigation.handleAction(Routes.WALLET_SCREEN, {}); + } else { + Navigation.goBack(); + } + }, screen: Screens.SWAPS, operation: TimeToSignOperation.SheetDismissal, endOfOperation: true, metadata: { degenMode: isDegenModeEnabled, }, - })(Routes.PROFILE_SCREEN, {}); + })(); analyticsV2.track(analyticsV2.event.swapsSubmitted, { type, diff --git a/src/navigation/Navigation.js b/src/navigation/Navigation.js index 03505cd2729..a1461bb567b 100644 --- a/src/navigation/Navigation.js +++ b/src/navigation/Navigation.js @@ -129,6 +129,7 @@ function setTopLevelNavigator(navigatorRef) { export default { getActiveOptions, + getState: () => TopLevelNavigationRef?.getState(), getActiveRoute, getActiveRouteName, handleAction, From 98d0151ef1679189f7da9bfe0734f23263f45788 Mon Sep 17 00:00:00 2001 From: gregs Date: Wed, 16 Oct 2024 13:52:49 -0300 Subject: [PATCH 2/3] Update src/__swaps__/screens/Swap/providers/swap-provider.tsx Co-authored-by: Matthew Wall --- src/__swaps__/screens/Swap/providers/swap-provider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__swaps__/screens/Swap/providers/swap-provider.tsx b/src/__swaps__/screens/Swap/providers/swap-provider.tsx index ad2761e9ab0..08b4a59b306 100644 --- a/src/__swaps__/screens/Swap/providers/swap-provider.tsx +++ b/src/__swaps__/screens/Swap/providers/swap-provider.tsx @@ -331,7 +331,7 @@ export const SwapProvider = ({ children }: SwapProviderProps) => { performanceTracking.getState().executeFn({ fn: () => { const { routes, index } = Navigation.getState(); - if (routes[index - 1].name === 'ExpandedAssetSheet') { + if (routes[index - 1].name === Routes.EXPANDED_ASSET_SHEET) { Navigation.handleAction(Routes.WALLET_SCREEN, {}); } else { Navigation.goBack(); From c8b61b68d343143c6e5aec3e3ba6d07e53d9618f Mon Sep 17 00:00:00 2001 From: gregs Date: Mon, 21 Oct 2024 16:21:51 -0300 Subject: [PATCH 3/3] handle index 0 --- src/__swaps__/screens/Swap/providers/swap-provider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__swaps__/screens/Swap/providers/swap-provider.tsx b/src/__swaps__/screens/Swap/providers/swap-provider.tsx index 08b4a59b306..42333c2a566 100644 --- a/src/__swaps__/screens/Swap/providers/swap-provider.tsx +++ b/src/__swaps__/screens/Swap/providers/swap-provider.tsx @@ -331,7 +331,7 @@ export const SwapProvider = ({ children }: SwapProviderProps) => { performanceTracking.getState().executeFn({ fn: () => { const { routes, index } = Navigation.getState(); - if (routes[index - 1].name === Routes.EXPANDED_ASSET_SHEET) { + if (index === 0 || routes[index - 1].name === Routes.EXPANDED_ASSET_SHEET) { Navigation.handleAction(Routes.WALLET_SCREEN, {}); } else { Navigation.goBack();