From cd7f4b270404cbf95e93a1d09d6991a433f75eb0 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 26 Jun 2024 13:06:29 +0200 Subject: [PATCH 1/3] Add actionName and actionParams variables to linkTo --- src/libs/Navigation/linkTo/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libs/Navigation/linkTo/index.ts b/src/libs/Navigation/linkTo/index.ts index 90e52d02163c..fd98f9341645 100644 --- a/src/libs/Navigation/linkTo/index.ts +++ b/src/libs/Navigation/linkTo/index.ts @@ -72,17 +72,21 @@ export default function linkTo(navigation: NavigationContainerRef | undefined, (value) => value === undefined), - omitBy(actionParams?.params as Record | undefined, (value) => value === undefined), + omitBy(actionParams as Record | undefined, (value) => value === undefined), ); // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH the new screen to the top of the stack by default @@ -110,8 +114,8 @@ export default function linkTo(navigation: NavigationContainerRef).policyIDs = policyID; + if (actionName === SCREENS.SEARCH.CENTRAL_PANE && actionParams && policyID) { + (actionParams as Record).policyIDs = policyID; } // If the type is UP, we deeplinked into one of the RHP flows and we want to replace the current screen with the previous one in the flow From 6e63dffbba939a21fa9896d797e81258bd7996db Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 26 Jun 2024 13:06:58 +0200 Subject: [PATCH 2/3] Refactor CENTRAL_PANE_SCREEN_NAMES to set --- src/libs/NavigationUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/NavigationUtils.ts b/src/libs/NavigationUtils.ts index f0442e4995d2..4fdc03c3d334 100644 --- a/src/libs/NavigationUtils.ts +++ b/src/libs/NavigationUtils.ts @@ -1,7 +1,7 @@ import SCREENS from '@src/SCREENS'; import type {CentralPaneName} from './Navigation/types'; -const CENTRAL_PANE_SCREEN_NAMES = [ +const CENTRAL_PANE_SCREEN_NAMES = new Set([ SCREENS.SETTINGS.WORKSPACES, SCREENS.SETTINGS.PREFERENCES.ROOT, SCREENS.SETTINGS.SECURITY, @@ -13,14 +13,14 @@ const CENTRAL_PANE_SCREEN_NAMES = [ SCREENS.SETTINGS.SUBSCRIPTION.ROOT, SCREENS.SEARCH.CENTRAL_PANE, SCREENS.REPORT, -]; +]); function isCentralPaneName(screen: string | undefined): screen is CentralPaneName { if (!screen) { return false; } - return CENTRAL_PANE_SCREEN_NAMES.includes(screen as CentralPaneName); + return CENTRAL_PANE_SCREEN_NAMES.has(screen as CentralPaneName); } export default isCentralPaneName; From 89b667668fc4c794fa35786126dcef1c64984ab8 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 26 Jun 2024 16:12:57 +0200 Subject: [PATCH 3/3] Rename actionName and actionParams variables in linkTo --- src/libs/Navigation/linkTo/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/Navigation/linkTo/index.ts b/src/libs/Navigation/linkTo/index.ts index fd98f9341645..3c4608d6b5de 100644 --- a/src/libs/Navigation/linkTo/index.ts +++ b/src/libs/Navigation/linkTo/index.ts @@ -76,17 +76,17 @@ export default function linkTo(navigation: NavigationContainerRef | undefined, (value) => value === undefined), - omitBy(actionParams as Record | undefined, (value) => value === undefined), + omitBy(targetParams as Record | undefined, (value) => value === undefined), ); // If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH the new screen to the top of the stack by default @@ -114,8 +114,8 @@ export default function linkTo(navigation: NavigationContainerRef).policyIDs = policyID; + if (targetName === SCREENS.SEARCH.CENTRAL_PANE && targetParams && policyID) { + (targetParams as Record).policyIDs = policyID; } // If the type is UP, we deeplinked into one of the RHP flows and we want to replace the current screen with the previous one in the flow