Skip to content

Commit 045f492

Browse files
authored
Merge pull request #10201 from Expensify/update-staging-from-main
Update version to 1.1.87-6 on staging
2 parents e54c083 + 465f461 commit 045f492

File tree

13 files changed

+61
-93
lines changed

13 files changed

+61
-93
lines changed

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ android {
152152
minSdkVersion rootProject.ext.minSdkVersion
153153
targetSdkVersion rootProject.ext.targetSdkVersion
154154
multiDexEnabled rootProject.ext.multiDexEnabled
155-
versionCode 1001018705
156-
versionName "1.1.87-5"
155+
versionCode 1001018706
156+
versionName "1.1.87-6"
157157
}
158158
splits {
159159
abi {

ios/NewExpensify/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</dict>
3131
</array>
3232
<key>CFBundleVersion</key>
33-
<string>1.1.87.5</string>
33+
<string>1.1.87.6</string>
3434
<key>ITSAppUsesNonExemptEncryption</key>
3535
<false/>
3636
<key>LSApplicationQueriesSchemes</key>

ios/NewExpensifyTests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>1.1.87.5</string>
22+
<string>1.1.87.6</string>
2323
</dict>
2424
</plist>

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "new.expensify",
3-
"version": "1.1.87-5",
3+
"version": "1.1.87-6",
44
"author": "Expensify, Inc.",
55
"homepage": "https://new.expensify.com",
66
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",

src/ONYXKEYS.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ export default {
2828
// Note: These are Persisted Requests - not all requests in the main queue as the key name might lead one to believe
2929
PERSISTED_REQUESTS: 'networkRequestQueue',
3030

31-
// What the active route is for our navigator. Global route that determines what views to display.
32-
CURRENT_URL: 'currentURL',
33-
3431
// Stores current date
3532
CURRENT_DATE: 'currentDate',
3633

src/libs/Navigation/AppNavigator/AuthScreens.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Onyx, {withOnyx} from 'react-native-onyx';
33
import moment from 'moment';
44
import _ from 'underscore';
55
import lodashGet from 'lodash/get';
6+
import PropTypes from 'prop-types';
67
import * as StyleUtils from '../../../styles/StyleUtils';
78
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
89
import CONST from '../../../CONST';
@@ -86,6 +87,9 @@ const modalScreenListeners = {
8687

8788
const propTypes = {
8889
...windowDimensionsPropTypes,
90+
91+
/** The current path as reported by the NavigationContainer */
92+
currentPath: PropTypes.string.isRequired,
8993
};
9094

9195
class AuthScreens extends React.Component {
@@ -115,7 +119,6 @@ class AuthScreens extends React.Component {
115119
App.openApp(this.props.allPolicies);
116120

117121
App.fixAccountAndReloadData();
118-
App.setUpPoliciesAndNavigate(this.props.session);
119122
Timing.end(CONST.TIMING.HOMEPAGE_INITIAL_RENDER);
120123

121124
const searchShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SEARCH;
@@ -133,6 +136,11 @@ class AuthScreens extends React.Component {
133136
}
134137

135138
shouldComponentUpdate(nextProps) {
139+
// we perform this check here instead of componentDidUpdate to skip an unnecessary re-render
140+
if (this.props.currentPath !== nextProps.currentPath) {
141+
App.setUpPoliciesAndNavigate(nextProps.session, nextProps.currentPath);
142+
}
143+
136144
return nextProps.isSmallScreenWidth !== this.props.isSmallScreenWidth;
137145
}
138146

src/libs/Navigation/AppNavigator/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import AuthScreens from './AuthScreens';
66
const propTypes = {
77
/** If we have an authToken this is true */
88
authenticated: PropTypes.bool.isRequired,
9+
10+
/** The current path as reported by the NavigationContainer */
11+
currentPath: PropTypes.string.isRequired,
912
};
1013

1114
const AppNavigator = props => (
1215
props.authenticated
1316
? (
1417

1518
// These are the protected screens and only accessible when an authToken is present
16-
<AuthScreens />
19+
<AuthScreens currentPath={props.currentPath} />
1720
)
1821
: (
1922
<PublicScreens />

src/libs/Navigation/Navigation.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ import ONYXKEYS from '../../ONYXKEYS';
1010
import linkingConfig from './linkingConfig';
1111
import navigationRef from './navigationRef';
1212

13-
let resolveNavigationIsReadyPromise;
14-
let navigationIsReadyPromise = new Promise((resolve) => {
15-
resolveNavigationIsReadyPromise = resolve;
16-
});
17-
1813
let isLoggedIn = false;
1914
Onyx.connect({
2015
key: ONYXKEYS.SESSION,
@@ -191,23 +186,6 @@ function isActiveRoute(routePath) {
191186
return getActiveRoute().substring(1) === routePath;
192187
}
193188

194-
/**
195-
* @returns {Promise}
196-
*/
197-
function isNavigationReady() {
198-
return navigationIsReadyPromise;
199-
}
200-
201-
function setIsNavigationReady() {
202-
resolveNavigationIsReadyPromise();
203-
}
204-
205-
function resetIsNavigationReady() {
206-
navigationIsReadyPromise = new Promise((resolve) => {
207-
resolveNavigationIsReadyPromise = resolve;
208-
});
209-
}
210-
211189
export default {
212190
canNavigate,
213191
navigate,
@@ -218,9 +196,6 @@ export default {
218196
closeDrawer,
219197
getDefaultDrawerState,
220198
setDidTapNotification,
221-
isNavigationReady,
222-
setIsNavigationReady,
223-
resetIsNavigationReady,
224199
};
225200

226201
export {

src/libs/Navigation/NavigationRoot.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {getPathFromState, NavigationContainer, DefaultTheme} from '@react-naviga
44
import * as Navigation from './Navigation';
55
import linkingConfig from './linkingConfig';
66
import AppNavigator from './AppNavigator';
7-
import * as App from '../actions/App';
87
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
98
import Log from '../Log';
109
import colors from '../../styles/colors';
@@ -31,6 +30,10 @@ class NavigationRoot extends Component {
3130
constructor(props) {
3231
super(props);
3332

33+
this.state = {
34+
currentPath: '',
35+
};
36+
3437
this.parseAndStoreRoute = this.parseAndStoreRoute.bind(this);
3538
}
3639

@@ -43,15 +46,16 @@ class NavigationRoot extends Component {
4346
return;
4447
}
4548

46-
const path = getPathFromState(state, linkingConfig.config);
49+
const currentPath = getPathFromState(state, linkingConfig.config);
4750

4851
// Don't log the route transitions from OldDot because they contain authTokens
49-
if (path.includes('/transition')) {
52+
if (currentPath.includes('/transition')) {
5053
Log.info('Navigating from transition link from OldDot using short lived authToken');
5154
} else {
52-
Log.info('Navigating to route', false, {path});
55+
Log.info('Navigating to route', false, {path: currentPath});
5356
}
54-
App.setCurrentURL(path);
57+
58+
this.setState({currentPath});
5559
}
5660

5761
render() {
@@ -72,7 +76,7 @@ class NavigationRoot extends Component {
7276
enabled: false,
7377
}}
7478
>
75-
<AppNavigator authenticated={this.props.authenticated} />
79+
<AppNavigator authenticated={this.props.authenticated} currentPath={this.state.currentPath} />
7680
</NavigationContainer>
7781
);
7882
}

src/libs/actions/App.js

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import moment from 'moment-timezone';
2-
import {AppState, Linking} from 'react-native';
2+
import {AppState} from 'react-native';
33
import Onyx from 'react-native-onyx';
44
import lodashGet from 'lodash/get';
55
import Str from 'expensify-common/lib/str';
@@ -54,13 +54,6 @@ Onyx.connect({
5454
},
5555
});
5656

57-
/**
58-
* @param {String} url
59-
*/
60-
function setCurrentURL(url) {
61-
Onyx.set(ONYXKEYS.CURRENT_URL, url);
62-
}
63-
6457
/**
6558
* @param {String} locale
6659
*/
@@ -165,13 +158,10 @@ function fixAccountAndReloadData() {
165158
}
166159

167160
/**
168-
* This action runs every time the AuthScreens are mounted. The navigator may
169-
* not be ready yet, and therefore we need to wait before navigating within this
170-
* action and any actions this method calls.
161+
* This action runs when the Navigator is ready and the current route changes
162+
*
163+
* currentPath should be the path as reported by the NavigationContainer
171164
*
172-
* getInitialURL allows us to access params from the transition link more easily
173-
* than trying to extract them from the navigation state.
174-
175165
* The transition link contains an exitTo param that contains the route to
176166
* navigate to after the user is signed in. A user can transition from OldDot
177167
* with a different account than the one they are currently signed in with, so
@@ -186,33 +176,36 @@ function fixAccountAndReloadData() {
186176
* pass it in as a parameter. withOnyx guarantees that the value has been read
187177
* from Onyx because it will not render the AuthScreens until that point.
188178
* @param {Object} session
179+
* @param {string} currentPath
189180
*/
190-
function setUpPoliciesAndNavigate(session) {
191-
Linking.getInitialURL()
192-
.then((url) => {
193-
if (!url) {
194-
return;
195-
}
196-
const path = new URL(url).pathname;
197-
const params = new URLSearchParams(url);
198-
const exitTo = params.get('exitTo');
199-
const isLoggingInAsNewUser = SessionUtils.isLoggingInAsNewUser(url, session.email);
200-
const shouldCreateFreePolicy = !isLoggingInAsNewUser
201-
&& Str.startsWith(path, Str.normalizeUrl(ROUTES.TRANSITION_FROM_OLD_DOT))
181+
function setUpPoliciesAndNavigate(session, currentPath) {
182+
if (!session || !currentPath || !currentPath.includes('exitTo')) {
183+
return;
184+
}
185+
186+
let exitTo;
187+
try {
188+
const url = new URL(currentPath, CONST.NEW_EXPENSIFY_URL);
189+
exitTo = url.searchParams.get('exitTo');
190+
} catch (error) {
191+
// URLSearchParams is unsupported on iOS so we catch th error and
192+
// silence it here since this is primarily a Web flow
193+
return;
194+
}
195+
196+
const isLoggingInAsNewUser = SessionUtils.isLoggingInAsNewUser(currentPath, session.email);
197+
const shouldCreateFreePolicy = !isLoggingInAsNewUser
198+
&& Str.startsWith(currentPath, Str.normalizeUrl(ROUTES.TRANSITION_FROM_OLD_DOT))
202199
&& exitTo === ROUTES.WORKSPACE_NEW;
203-
if (shouldCreateFreePolicy) {
204-
Policy.createAndGetPolicyList();
205-
return;
206-
}
207-
if (!isLoggingInAsNewUser && exitTo) {
208-
Navigation.isNavigationReady()
209-
.then(() => {
210-
// We must call dismissModal() to remove the /transition route from history
211-
Navigation.dismissModal();
212-
Navigation.navigate(exitTo);
213-
});
214-
}
215-
});
200+
if (shouldCreateFreePolicy) {
201+
Policy.createAndGetPolicyList();
202+
return;
203+
}
204+
if (!isLoggingInAsNewUser && exitTo) {
205+
// We must call dismissModal() to remove the /transition route from history
206+
Navigation.dismissModal();
207+
Navigation.navigate(exitTo);
208+
}
216209
}
217210

218211
function openProfile() {
@@ -255,7 +248,6 @@ NetworkConnection.onReconnect(() => {
255248
});
256249

257250
export {
258-
setCurrentURL,
259251
setLocale,
260252
setSidebarLoaded,
261253
getAppData,

src/libs/actions/Policy.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ function createAndGetPolicyList() {
238238
newPolicyID = policyID;
239239
return getPolicyList();
240240
})
241-
.then(Navigation.isNavigationReady)
242241
.then(() => {
243242
Navigation.dismissModal();
244243
navigateToPolicy(newPolicyID);

src/pages/LogOutPreviousUserPage.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {withOnyx} from 'react-native-onyx';
66
import ONYXKEYS from '../ONYXKEYS';
77
import * as Session from '../libs/actions/Session';
88
import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator';
9-
import Navigation from '../libs/Navigation/Navigation';
109
import * as SessionUtils from '../libs/SessionUtils';
1110

1211
const propTypes = {
@@ -25,16 +24,7 @@ class LogOutPreviousUserPage extends Component {
2524
const isLoggingInAsNewUser = SessionUtils.isLoggingInAsNewUser(transitionURL, sessionEmail);
2625
if (isLoggingInAsNewUser) {
2726
Session.signOutAndRedirectToSignIn();
28-
return;
2927
}
30-
31-
// Since we conditionally render navigators in the AppNavigator, when we
32-
// sign out and sign back in there will be a moment where no navigator
33-
// is rendered and the navigation state is null. We can't navigate at
34-
// that time, so we use a promise to delay transition navigation until
35-
// it is ready. We set the navigation ready here since we know that the
36-
// navigator is now rendered.
37-
Navigation.setIsNavigationReady();
3828
});
3929
}
4030

0 commit comments

Comments
 (0)