Skip to content

Commit

Permalink
Remove Navigation.isNavigating
Browse files Browse the repository at this point in the history
  • Loading branch information
aldo-expensify committed Mar 16, 2023
1 parent 4952847 commit b659e1b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
9 changes: 0 additions & 9 deletions src/components/ScreenWrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ class ScreenWrapper extends React.Component {
Navigation.dismissModal();
}, shortcutConfig.descriptionKey, shortcutConfig.modifiers, true);

this.unsubscribeTransitionStart = this.props.navigation.addListener('transitionStart', () => {
Navigation.setIsNavigating(true);
});

this.unsubscribeTransitionEnd = this.props.navigation.addListener('transitionEnd', (event) => {
Navigation.setIsNavigating(false);

// Prevent firing the prop callback when user is exiting the page.
if (lodashGet(event, 'data.closing')) {
return;
Expand Down Expand Up @@ -85,9 +79,6 @@ class ScreenWrapper extends React.Component {
if (this.unsubscribeTransitionEnd) {
this.unsubscribeTransitionEnd();
}
if (this.unsubscribeTransitionStart) {
this.unsubscribeTransitionStart();
}
if (this.beforeRemoveSubscription) {
this.beforeRemoveSubscription();
}
Expand Down
19 changes: 1 addition & 18 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const reportScreenIsReadyPromise = new Promise((resolve) => {

let isLoggedIn = false;
let pendingRoute = null;
let isNavigating = false;

Onyx.connect({
key: ONYXKEYS.SESSION,
Expand All @@ -55,27 +54,13 @@ function setDidTapNotification() {
* @returns {Boolean}
*/
function canNavigate(methodName, params = {}) {
if (navigationRef.isReady() && !isNavigating) {
if (navigationRef.isReady()) {
return true;
}

if (isNavigating) {
Log.hmmm(`[Navigation] ${methodName} failed because navigation is progress`, params);
return false;
}

Log.hmmm(`[Navigation] ${methodName} failed because navigation ref was not yet ready`, params);
return false;
}

/**
* Sets Navigation State
* @param {Boolean} isNavigatingValue
*/
function setIsNavigating(isNavigatingValue) {
isNavigating = isNavigatingValue;
}

/**
* Opens the LHN drawer.
* @private
Expand Down Expand Up @@ -128,7 +113,6 @@ function goBack(shouldOpenDrawer = true) {
}
return;
}

navigationRef.current.goBack();
}

Expand Down Expand Up @@ -309,7 +293,6 @@ export default {
setIsDrawerReady,
resetDrawerIsReadyPromise,
isDrawerRoute,
setIsNavigating,
isReportScreenReady,
setIsReportScreenIsReady,
};
Expand Down

0 comments on commit b659e1b

Please sign in to comment.