Skip to content

Commit

Permalink
partial revert
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragsalian committed Sep 8, 2022
1 parent d7a7334 commit 46c7c43
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ const CONST = {
FREE: 'free',
PERSONAL: 'personal',
CORPORATE: 'corporate',
TEAM: 'team',
},
ROLE: {
ADMIN: 'admin',
Expand Down
9 changes: 8 additions & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Onyx, {withOnyx} from 'react-native-onyx';
import moment from 'moment';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import * as StyleUtils from '../../../styles/StyleUtils';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import CONST from '../../../CONST';
Expand Down Expand Up @@ -86,6 +87,9 @@ const modalScreenListeners = {

const propTypes = {
...windowDimensionsPropTypes,

/** The current path as reported by the NavigationContainer */
currentPath: PropTypes.string.isRequired,
};

class AuthScreens extends React.Component {
Expand All @@ -112,7 +116,6 @@ class AuthScreens extends React.Component {
// Listen for report changes and fetch some data we need on initialization
UnreadIndicatorUpdater.listenForReportChanges();
App.openApp();
App.setUpPoliciesAndNavigate(this.props.session);
Timing.end(CONST.TIMING.HOMEPAGE_INITIAL_RENDER);

const searchShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SEARCH;
Expand All @@ -130,6 +133,10 @@ class AuthScreens extends React.Component {
}

shouldComponentUpdate(nextProps) {
// we perform this check here instead of componentDidUpdate to skip an unnecessary re-render
if (this.props.currentPath !== nextProps.currentPath) {
App.setUpPoliciesAndNavigate(nextProps.session, nextProps.currentPath);
}
return nextProps.isSmallScreenWidth !== this.props.isSmallScreenWidth;
}

Expand Down
5 changes: 4 additions & 1 deletion src/libs/Navigation/AppNavigator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import AuthScreens from './AuthScreens';
const propTypes = {
/** If we have an authToken this is true */
authenticated: PropTypes.bool.isRequired,

/** The current path as reported by the NavigationContainer */
currentPath: PropTypes.string.isRequired,
};

const AppNavigator = props => (
props.authenticated
? (

// These are the protected screens and only accessible when an authToken is present
<AuthScreens />
<AuthScreens currentPath={props.currentPath} />
)
: (
<PublicScreens />
Expand Down
14 changes: 13 additions & 1 deletion src/libs/Navigation/NavigationRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ const propTypes = {
};

class NavigationRoot extends Component {
constructor(props) {
super(props);

this.state = {
currentPath: '',
};

this.parseAndLogRoute = this.parseAndLogRoute.bind(this);
}

/**
* Intercept navigation state changes and log it
* @param {NavigationState} state
Expand All @@ -47,6 +57,8 @@ class NavigationRoot extends Component {
}

UnreadIndicatorUpdater.throttledUpdatePageTitleAndUnreadCount();

this.setState({currentPath});
}

render() {
Expand All @@ -67,7 +79,7 @@ class NavigationRoot extends Component {
enabled: false,
}}
>
<AppNavigator authenticated={this.props.authenticated} />
<AppNavigator authenticated={this.props.authenticated} currentPath={this.state.currentPath} />
</NavigationContainer>
);
}
Expand Down

0 comments on commit 46c7c43

Please sign in to comment.