Skip to content

Commit

Permalink
Merge pull request #37194 from MrRefactor/proposal/34523
Browse files Browse the repository at this point in the history
Update the version of react-navigation/native
  • Loading branch information
roryabraham committed Mar 1, 2024
2 parents cda8b87 + ad8a707 commit a778b0a
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 39 deletions.
9 changes: 7 additions & 2 deletions .github/actions/javascript/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2657,12 +2657,17 @@ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`)

// Coercion.
// Extract anything that could conceivably be a part of a valid semver
createToken('COERCE', `${'(^|[^\\d])' +
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`)
createToken('COERCEFULL', src[t.COERCEPLAIN] +
`(?:${src[t.PRERELEASE]})?` +
`(?:${src[t.BUILD]})?` +
`(?:$|[^\\d])`)
createToken('COERCERTL', src[t.COERCE], true)
createToken('COERCERTLFULL', src[t.COERCEFULL], true)

// Tilde ranges.
// Meaning is "reasonably at or greater than"
Expand Down
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@react-native-google-signin/google-signin": "^10.0.1",
"@react-native-picker/picker": "2.5.1",
"@react-navigation/material-top-tabs": "^6.6.3",
"@react-navigation/native": "6.1.8",
"@react-navigation/native": "6.1.12",
"@react-navigation/stack": "6.3.16",
"@react-ng/bounds-observer": "^0.2.1",
"@rnmapbox/maps": "^10.1.11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ index 0000000..16da117
+//# sourceMappingURL=findFocusedRouteKey.js.map
\ No newline at end of file
diff --git a/node_modules/@react-navigation/native/lib/module/useLinking.js b/node_modules/@react-navigation/native/lib/module/useLinking.js
index 6f0ac51..a77b608 100644
index 6688c62..95a0e32 100644
--- a/node_modules/@react-navigation/native/lib/module/useLinking.js
+++ b/node_modules/@react-navigation/native/lib/module/useLinking.js
@@ -2,6 +2,7 @@ import { findFocusedRoute, getActionFromState as getActionFromStateDefault, getP
Expand Down Expand Up @@ -189,17 +189,17 @@ index 6f0ac51..a77b608 100644
export default function useLinking(ref, _ref) {
let {
independent,
@@ -231,6 +270,9 @@ export default function useLinking(ref, _ref) {
@@ -234,6 +273,9 @@ export default function useLinking(ref, _ref) {
// Otherwise it's likely a change triggered by `popstate`
path !== pendingPath) {
const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);
+
+
+ // The historyDelta and historyDeltaByKeys may differ if the new state has an entry that didn't exist in previous state
+ const historyDeltaByKeys = getHistoryDeltaByKeys(focusedState, previousFocusedState);
if (historyDelta > 0) {
// If history length is increased, we should pushState
// Note that path might not actually change here, for example, drawer open should pushState
@@ -242,34 +284,55 @@ export default function useLinking(ref, _ref) {
@@ -245,7 +287,8 @@ export default function useLinking(ref, _ref) {
// If history length is decreased, i.e. entries were removed, we want to go back

const nextIndex = history.backIndex({
Expand All @@ -209,7 +209,8 @@ index 6f0ac51..a77b608 100644
});
const currentIndex = history.index;
try {
if (nextIndex !== -1 && nextIndex < currentIndex) {
@@ -254,27 +297,47 @@ export default function useLinking(ref, _ref) {
history.get(nextIndex - currentIndex)) {
// An existing entry for this path exists and it's less than current index, go back to that
await history.go(nextIndex - currentIndex);
+ history.replace({
Expand Down Expand Up @@ -263,7 +264,7 @@ index 6f0ac51..a77b608 100644
+ path,
+ state
+ });
+ }
+ }
}
} else {
// If no common navigation state was found, assume it's a replace
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import getTopmostBottomTabRoute from '@libs/Navigation/getTopmostBottomTabRoute';
import Navigation from '@libs/Navigation/Navigation';
import type {RootStackParamList} from '@libs/Navigation/types';
import type {RootStackParamList, State} from '@libs/Navigation/types';
import {checkIfWorkspaceSettingsTabHasRBR, getChatTabBrickRoad} from '@libs/WorkspacesSettingsUtils';
import BottomTabBarFloatingActionButton from '@pages/home/sidebar/BottomTabBarFloatingActionButton';
import variables from '@styles/variables';
Expand All @@ -39,9 +39,9 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps
const navigation = useNavigation();

useEffect(() => {
const navigationState = navigation.getState();
const routes = navigationState.routes;
const currentRoute = routes[navigationState.index];
const navigationState = navigation.getState() as State<RootStackParamList> | undefined;
const routes = navigationState?.routes;
const currentRoute = routes?.[navigationState?.index ?? 0];
const bottomTabRoute = getTopmostBottomTabRoute(navigationState);
if (
// When we are redirected to the Settings tab from the OldDot, we don't want to call the Welcome.show() method.
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/FreezeWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function FreezeWrapper({keepVisible = false, children}: FreezeWrapperProps) {
const currentRoute = useRoute();

useEffect(() => {
const index = navigation.getState().routes.findIndex((route) => route.key === currentRoute.key);
const index = navigation.getState()?.routes.findIndex((route) => route.key === currentRoute.key) ?? 0;
screenIndexRef.current = index;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand All @@ -28,7 +28,7 @@ function FreezeWrapper({keepVisible = false, children}: FreezeWrapperProps) {
// if the screen is more than 1 screen away from the current screen, freeze it,
// we don't want to freeze the screen if it's the previous screen because the freeze placeholder
// would be visible at the beginning of the back animation then
if (navigation.getState().index - (screenIndexRef.current ?? 0) > 1) {
if ((navigation.getState()?.index ?? 0) - (screenIndexRef.current ?? 0) > 1) {
InteractionManager.runAfterInteractions(() => setIsScreenBlurred(true));
} else {
setIsScreenBlurred(false);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/getTopmostBottomTabRoute.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {BottomTabName, NavigationPartialRoute, RootStackParamList, State} from './types';

function getTopmostBottomTabRoute(state: State<RootStackParamList>): NavigationPartialRoute<BottomTabName> | undefined {
const bottomTabNavigatorRoute = state.routes[0];
function getTopmostBottomTabRoute(state: State<RootStackParamList> | undefined): NavigationPartialRoute<BottomTabName> | undefined {
const bottomTabNavigatorRoute = state?.routes[0];

// The bottomTabNavigatorRoute state may be empty if we just logged in.
if (!bottomTabNavigatorRoute || bottomTabNavigatorRoute.name !== 'BottomTabNavigator' || bottomTabNavigatorRoute.state === undefined) {
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Welcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {OnyxCollection} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import type {RootStackParamList} from '@navigation/types';
import type {RootStackParamList, State} from '@navigation/types';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -125,15 +125,15 @@ Onyx.connect({
/**
* Shows a welcome action on first login
*/
function show(routes: NavigationState<RootStackParamList>['routes'], showEngagementModal = () => {}) {
function show(routes: State<RootStackParamList>['routes'] | undefined, showEngagementModal = () => {}) {
isReadyPromise.then(() => {
if (!isFirstTimeNewExpensifyUser) {
return;
}

// If we are rendering the SidebarScreen at the same time as a workspace route that means we've already created a workspace via workspace/new and should not open the global
// create menu right now. We should also stay on the workspace page if that is our destination.
const transitionRoute = routes.find(
const transitionRoute = routes?.find(
(route): route is NavigationState<Pick<RootStackParamList, typeof SCREENS.TRANSITION_BETWEEN_APPS>>['routes'][number] => route.name === SCREENS.TRANSITION_BETWEEN_APPS,
);
const isExitingToWorkspaceRoute = transitionRoute?.params?.exitTo === 'workspace/new';
Expand Down

0 comments on commit a778b0a

Please sign in to comment.