Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Revert #9706. Rename file to DeprecatedCustomActions.js to prevent further editing #10101

Merged
merged 2 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import {
CommonActions, StackActions, DrawerActions, getStateFromPath,
} from '@react-navigation/native';
import lodashGet from 'lodash/get';
import {Dimensions} from 'react-native';
import linkingConfig from './linkingConfig';
import navigationRef from './navigationRef';
import variables from '../../styles/variables';

/**
* @returns {Object}
Expand All @@ -18,6 +16,7 @@ function getActiveState() {

/**
* Go back to the Main Drawer
* @deprecated
* @param {Object} navigationRef
*/
function navigateBackToRootDrawer() {
Expand Down Expand Up @@ -66,14 +65,12 @@ function getScreenNameFromState(state) {
*
* More context here: https://github.com/react-navigation/react-navigation/issues/9744
*
* @deprecated
* @param {String} route
* @returns {Function}
*/
function pushDrawerRoute(route) {
return (currentState) => {
const initialDimensions = Dimensions.get('window');
const isSmallScreenWidth = initialDimensions.width <= variables.mobileResponsiveWidthBreakpoint;

// Parse the state, name, and params from the new route we want to navigate to.
const newStateFromRoute = getStateFromPath(route, linkingConfig.config);
const newScreenName = getScreenNameFromState(newStateFromRoute);
Expand Down Expand Up @@ -108,18 +105,13 @@ function pushDrawerRoute(route) {
// Force drawer to close
// https://github.com/react-navigation/react-navigation/blob/94ab791cae5061455f036cd3f6bc7fa63167e7c7/packages/routers/src/DrawerRouter.tsx#L142
const hasDrawerhistory = _.find(state.history || [], h => h.type === 'drawer');
if (isSmallScreenWidth && (!hasDrawerhistory || currentState.type !== 'drawer')) {
if (!hasDrawerhistory || currentState.type !== 'drawer') {
history.push({
type: 'drawer',

// If current state is not from drawer navigator then always use closed status to close the drawer
status: currentState.type !== 'drawer' || currentState.default === 'open' ? 'closed' : 'open',
});
} else {
history.push({
type: 'route',
name: newScreenName,
});
}

return CommonActions.reset({
Expand Down
6 changes: 3 additions & 3 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Onyx from 'react-native-onyx';
import Log from '../Log';
import linkTo from './linkTo';
import ROUTES from '../../ROUTES';
import CustomActions from './CustomActions';
import DeprecatedCustomActions from './DeprecatedCustomActions';
import ONYXKEYS from '../../ONYXKEYS';
import linkingConfig from './linkingConfig';
import navigationRef from './navigationRef';
Expand Down Expand Up @@ -140,7 +140,7 @@ function navigate(route = ROUTES.HOME) {
}

if (isDrawerRoute(route)) {
navigationRef.current.dispatch(CustomActions.pushDrawerRoute(route));
navigationRef.current.dispatch(DeprecatedCustomActions.pushDrawerRoute(route));
return;
}

Expand All @@ -161,7 +161,7 @@ function dismissModal(shouldOpenDrawer = false) {
? shouldOpenDrawer
: false;

CustomActions.navigateBackToRootDrawer();
DeprecatedCustomActions.navigateBackToRootDrawer();
if (normalizedShouldOpenDrawer) {
openDrawer();
}
Expand Down