-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #47787 from software-mansion-labs/kicu/policy-ids-…
…query [Search] Move policyID into Search query syntax and remove policyIDs param
- Loading branch information
Showing
22 changed files
with
263 additions
and
133 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
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
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,22 @@ | ||
import * as SearchUtils from '@libs/SearchUtils'; | ||
import type {NavigationPartialRoute} from './types'; | ||
|
||
function extractPolicyIDFromQuery(route?: NavigationPartialRoute<string>) { | ||
if (!route?.params) { | ||
return undefined; | ||
} | ||
|
||
if (!('q' in route.params)) { | ||
return undefined; | ||
} | ||
|
||
const queryString = route.params.q as string; | ||
const queryJSON = SearchUtils.buildSearchQueryJSON(queryString); | ||
if (!queryJSON) { | ||
return undefined; | ||
} | ||
|
||
return SearchUtils.getPolicyIDFromSearchQuery(queryJSON); | ||
} | ||
|
||
export default extractPolicyIDFromQuery; |
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,16 +1,23 @@ | ||
import extractPolicyIDFromQuery from './extractPolicyIDFromQuery'; | ||
import getTopmostBottomTabRoute from './getTopmostBottomTabRoute'; | ||
import type {RootStackParamList, State} from './types'; | ||
|
||
/** | ||
* returns policyID value if one exists in navigation state | ||
* | ||
* PolicyID in this app can be stored in two ways: | ||
* - on most screens but NOT Search as `policyID` param | ||
* - on Search related screens as policyID filter inside `q` (SearchQuery) param | ||
*/ | ||
const getPolicyIDFromState = (state: State<RootStackParamList>): string | undefined => { | ||
const topmostBottomTabRoute = getTopmostBottomTabRoute(state); | ||
|
||
const shouldAddPolicyIDToUrl = !!topmostBottomTabRoute && !!topmostBottomTabRoute.params && 'policyID' in topmostBottomTabRoute.params && !!topmostBottomTabRoute.params?.policyID; | ||
|
||
if (!shouldAddPolicyIDToUrl) { | ||
return undefined; | ||
const policyID = topmostBottomTabRoute && topmostBottomTabRoute.params && 'policyID' in topmostBottomTabRoute.params && topmostBottomTabRoute.params?.policyID; | ||
if (policyID) { | ||
return topmostBottomTabRoute.params?.policyID as string; | ||
} | ||
|
||
return topmostBottomTabRoute.params?.policyID as string; | ||
return extractPolicyIDFromQuery(topmostBottomTabRoute); | ||
}; | ||
|
||
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
13 changes: 0 additions & 13 deletions
13
src/libs/Navigation/linkingConfig/extractPolicyIDsFromState.ts
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.