Skip to content

Commit

Permalink
completing a swap navigates back to previous screen (#6207)
Browse files Browse the repository at this point in the history
* complete swap navigate back to previous screen

* Update src/__swaps__/screens/Swap/providers/swap-provider.tsx

Co-authored-by: Matthew Wall <[email protected]>

* handle index 0

---------

Co-authored-by: Matthew Wall <[email protected]>
  • Loading branch information
greg-schrammel and walmat authored Oct 22, 2024
1 parent 646902f commit 05e1427
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/__swaps__/screens/Swap/providers/swap-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function setTopLevelNavigator(navigatorRef) {

export default {
getActiveOptions,
getState: () => TopLevelNavigationRef?.getState(),
getActiveRoute,
getActiveRouteName,
handleAction,
Expand Down

0 comments on commit 05e1427

Please sign in to comment.