Skip to content

Commit

Permalink
Merge pull request #29708 from Expensify/francoisl-cherry-pick-stagin…
Browse files Browse the repository at this point in the history
…g-29706-1
  • Loading branch information
francoisl authored Oct 16, 2023
2 parents 17214bf + 2a096a0 commit 89c74b5
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 85 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001038409
versionName "1.3.84-9"
versionCode 1001038410
versionName "1.3.84-10"
}

flavorDimensions "default"
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.3.84.9</string>
<string>1.3.84.10</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.84.9</string>
<string>1.3.84.10</string>
</dict>
</plist>
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.3.84-9",
"version": "1.3.84-10",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
17 changes: 6 additions & 11 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
* This is a file containing constants for all of the screen names. In most cases, we should use the routes for
* navigation. But there are situations where we may need to access screen names directly.
*/
const PROTECTED_SCREENS = {
HOME: 'Home',
CONCIERGE: 'Concierge',
REPORT_ATTACHMENTS: 'ReportAttachments',
} as const;

export default {
...PROTECTED_SCREENS,
HOME: 'Home',
LOADING: 'Loading',
REPORT: 'Report',
REPORT_ATTACHMENTS: 'ReportAttachments',
NOT_FOUND: 'not-found',
TRANSITION_BETWEEN_APPS: 'TransitionBetweenApps',
VALIDATE_LOGIN: 'ValidateLogin',
CONCIERGE: 'Concierge',
SETTINGS: {
ROOT: 'Settings_Root',
PREFERENCES: 'Settings_Preferences',
Expand All @@ -25,11 +23,10 @@ export default {
SAVE_THE_WORLD: {
ROOT: 'SaveTheWorld_Root',
},
TRANSITION_BETWEEN_APPS: 'TransitionBetweenApps',
SIGN_IN_WITH_APPLE_DESKTOP: 'AppleSignInDesktop',
SIGN_IN_WITH_GOOGLE_DESKTOP: 'GoogleSignInDesktop',
DESKTOP_SIGN_IN_REDIRECT: 'DesktopSignInRedirect',
VALIDATE_LOGIN: 'ValidateLogin',
SAML_SIGN_IN: 'SAMLSignIn',

// Iframe screens from olddot
HOME_OLDDOT: 'Home_OLDDOT',
Expand All @@ -44,5 +41,3 @@ export default {
GROUPS_WORKSPACES_OLDDOT: 'GroupWorkspaces_OLDDOT',
CARDS_AND_DOMAINS_OLDDOT: 'CardsAndDomains_OLDDOT',
} as const;

export {PROTECTED_SCREENS};
58 changes: 1 addition & 57 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import originalGetTopmostReportId from './getTopmostReportId';
import originalGetTopMostCentralPaneRouteName from './getTopMostCentralPaneRouteName';
import originalGetTopmostReportActionId from './getTopmostReportActionID';
import getStateFromPath from './getStateFromPath';
import SCREENS, {PROTECTED_SCREENS} from '../../SCREENS';
import SCREENS from '../../SCREENS';
import CONST from '../../CONST';

let resolveNavigationIsReadyPromise;
Expand Down Expand Up @@ -262,61 +262,6 @@ function setIsNavigationReady() {
resolveNavigationIsReadyPromise();
}

/**
* Checks if the navigation state contains routes that are protected (over the auth wall).
*
* @function
* @param {Object} state - react-navigation state object
*
* @returns {Boolean}
*/
function navContainsProtectedRoutes(state) {
if (!state || !state.routeNames || !_.isArray(state.routeNames)) {
return false;
}
const protectedScreensNames = _.values(PROTECTED_SCREENS);
const difference = _.difference(protectedScreensNames, state.routeNames);

return !difference.length;
}

/**
* Waits for the navigation state to contain protected routes specified in PROTECTED_SCREENS constant
* If the navigation is in a state, where protected routes are available, the promise will resolve immediately.
*
* @function
* @returns {Promise<void>} A promise that resolves to `true` when the Concierge route is present.
* Rejects with an error if the navigation is not ready.
*
* @example
* waitForProtectedRoutes()
* .then(() => console.log('Protected routes are present!'))
* .catch(error => console.error(error.message));
*/
function waitForProtectedRoutes() {
return new Promise((resolve, reject) => {
const isReady = navigationRef.current && navigationRef.current.isReady();
if (!isReady) {
reject(new Error('[Navigation] is not ready yet!'));
return;
}
const currentState = navigationRef.current.getState();
if (navContainsProtectedRoutes(currentState)) {
resolve();
return;
}
let unsubscribe;
const handleStateChange = ({data}) => {
const state = lodashGet(data, 'state');
if (navContainsProtectedRoutes(state)) {
unsubscribe();
resolve();
}
};
unsubscribe = navigationRef.current.addListener('state', handleStateChange);
});
}

export default {
setShouldPopAllStateOnUP,
canNavigate,
Expand All @@ -330,7 +275,6 @@ export default {
setIsNavigationReady,
getTopmostReportId,
getRouteNameFromStateEvent,
waitForProtectedRoutes,
getTopMostCentralPaneRouteName,
getTopmostReportActionId,
};
Expand Down
16 changes: 6 additions & 10 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,7 @@ function toggleEmojiReaction(reportID, reportAction, reactionObject, existingRea
* @param {Boolean} isAuthenticated
*/
function openReportFromDeepLink(url, isAuthenticated) {
const route = ReportUtils.getRouteFromLink(url);
const reportID = ReportUtils.getReportIDFromLink(url);

if (reportID && !isAuthenticated) {
Expand All @@ -1907,16 +1908,11 @@ function openReportFromDeepLink(url, isAuthenticated) {
// Navigate to the report after sign-in/sign-up.
InteractionManager.runAfterInteractions(() => {
Session.waitForUserSignIn().then(() => {
Navigation.waitForProtectedRoutes()
.then(() => {
const route = ReportUtils.getRouteFromLink(url);
if (route === ROUTES.CONCIERGE) {
navigateToConciergeChat(true);
return;
}
Navigation.navigate(route, CONST.NAVIGATION.TYPE.PUSH);
})
.catch((error) => Log.warn(error.message));
if (route === ROUTES.CONCIERGE) {
navigateToConciergeChat(true);
return;
}
Navigation.navigate(route, CONST.NAVIGATION.TYPE.PUSH);
});
});
}
Expand Down

0 comments on commit 89c74b5

Please sign in to comment.