From 05e14276ca3c51ba9a8170109f09ef7f985cefc8 Mon Sep 17 00:00:00 2001 From: gregs Date: Tue, 22 Oct 2024 16:39:15 -0300 Subject: [PATCH] completing a swap navigates back to previous screen (#6207) * complete swap navigate back to previous screen * Update src/__swaps__/screens/Swap/providers/swap-provider.tsx Co-authored-by: Matthew Wall * handle index 0 --------- Co-authored-by: Matthew Wall --- .../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..42333c2a566 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 (index === 0 || routes[index - 1].name === Routes.EXPANDED_ASSET_SHEET) { + 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,