forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from software-mansion-labs/ideal-nav-fix-path
fix path with policyId inside FullScreenSettings
- Loading branch information
Showing
10 changed files
with
58 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import getTopmostBottomTabRoute from './getTopmostBottomTabRoute'; | ||
import type {RootStackParamList, State} from './types'; | ||
|
||
const getPolicyIdFromState = (state: State<RootStackParamList>) => { | ||
const getPolicyIdFromState = (state: State<RootStackParamList>): string | undefined => { | ||
const topmostBottomTabRoute = getTopmostBottomTabRoute(state); | ||
|
||
const shouldAddPolicyIdToUrl = !!topmostBottomTabRoute && !!topmostBottomTabRoute.params && 'policyID' in topmostBottomTabRoute.params && !!topmostBottomTabRoute.params?.policyID; | ||
|
||
return shouldAddPolicyIdToUrl ? (topmostBottomTabRoute.params?.policyID as string) : ''; | ||
if (!shouldAddPolicyIdToUrl) { | ||
return undefined; | ||
} | ||
|
||
return topmostBottomTabRoute.params?.policyID as string; | ||
}; | ||
|
||
export default getPolicyIdFromState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/libs/Navigation/linkingConfig/replacePathInNestedState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import {findFocusedRoute} from '@react-navigation/native'; | ||
import type {NavigationState, PartialState} from '@react-navigation/native'; | ||
import type {RootStackParamList} from '@libs/Navigation/types'; | ||
|
||
function replacePathInNestedState(state: PartialState<NavigationState<RootStackParamList>>, path: string) { | ||
const found = findFocusedRoute(state); | ||
if (!found) { | ||
return; | ||
} | ||
|
||
// @ts-expect-error Updating read only property | ||
found.path = path; | ||
} | ||
export default replacePathInNestedState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters