Skip to content

Commit

Permalink
Merge branch 'main' into delay-focus-for-android-only
Browse files Browse the repository at this point in the history
  • Loading branch information
rushatgabhane committed Aug 3, 2022
2 parents 12e180d + 28778a0 commit 463dc8d
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 112 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ This application is built with the following principles.
- The UI should never call any Onyx methods except for `Onyx.connect()`. That is the job of Actions (see next section).
- The UI always triggers an Action when something needs to happen (eg. a person inputs data, the UI triggers an Action with this data).
- The UI should be as flexible as possible when it comes to:
- Incomplete or missing data. Always assume data is incomplete or not there. For example, when a comment is pushed to the client from a pusher event, it's possible that Onyx does not have data for that report yet. That's OK. A partial report object is added to Onyx for the report key `report_1234 = {reportID: 1234, isUnread: true}`. Then there is code that monitors Onyx for reports with incomplete data, and calls `fetchChatReportsByIDs(1234)` to get the full data for that report. The UI should be able to gracefully handle the report object not being complete. In this example, the sidebar wouldn't display any report that doesn't have a report name.
- Incomplete or missing data. Always assume data is incomplete or not there. For example, when a comment is pushed to the client from a pusher event, it's possible that Onyx does not have data for that report yet. That's OK. A partial report object is added to Onyx for the report key `report_1234 = {reportID: 1234, isUnread: true}`. Then there is code that monitors Onyx for reports with incomplete data, and calls `fetchChatReportsByIDs(1234)` to get the full data for that report. The UI should be able to gracefully handle the report object not being complete. In this example, the sidebar wouldn't display any report that does not have a report name.
- The order that actions are done in. All actions should be done in parallel instead of sequence.
- Parallel actions are asynchronous methods that don't return promises. Any number of these actions can be called at one time and it doesn't matter what order they happen in or when they complete.
- In-Sequence actions are asynchronous methods that return promises. This is necessary when one asynchronous method depends on the results from a previous asynchronous method. Example: Making an XHR to `command=CreateChatReport` which returns a reportID which is used to call `command=Get&rvl=reportStuff`.
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001018704
versionName "1.1.87-4"
versionCode 1001018708
versionName "1.1.87-8"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.1.87.4</string>
<string>1.1.87.8</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.1.87.4</string>
<string>1.1.87.8</string>
</dict>
</plist>
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.1.87-4",
"version": "1.1.87-8",
"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 Expand Up @@ -151,7 +151,7 @@
"copy-webpack-plugin": "^6.0.3",
"css-loader": "^5.2.4",
"diff-so-fancy": "^1.3.0",
"electron": "^17.4.5",
"electron": "^17.4.11",
"electron-builder": "^22.13.1",
"electron-notarize": "^1.2.1",
"electron-reloader": "^1.2.1",
Expand Down
3 changes: 0 additions & 3 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ export default {
// Note: These are Persisted Requests - not all requests in the main queue as the key name might lead one to believe
PERSISTED_REQUESTS: 'networkRequestQueue',

// What the active route is for our navigator. Global route that determines what views to display.
CURRENT_URL: 'currentURL',

// Stores current date
CURRENT_DATE: 'currentDate',

Expand Down
4 changes: 2 additions & 2 deletions src/components/OptionsSelector/BaseOptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class BaseOptionsSelector extends Component {
allOptions: newOptions,
focusedIndex: newFocusedIndex,
}, () => {
// If we just selected a new option on a multiple-selection page, scroll to the top
if (this.props.selectedOptions.length > prevProps.selectedOptions.length) {
// If we just toggled an option on a multi-selection page, scroll to top
if (this.props.selectedOptions.length !== prevProps.selectedOptions.length) {
this.scrollToIndex(0);
return;
}
Expand Down
10 changes: 9 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 Down Expand Up @@ -115,7 +119,6 @@ class AuthScreens extends React.Component {
App.openApp(this.props.allPolicies);

App.fixAccountAndReloadData();
App.setUpPoliciesAndNavigate(this.props.session);
Timing.end(CONST.TIMING.HOMEPAGE_INITIAL_RENDER);

const searchShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SEARCH;
Expand All @@ -133,6 +136,11 @@ 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
11 changes: 11 additions & 0 deletions src/libs/Navigation/AppNavigator/BaseDrawerNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ class BaseDrawerNavigator extends Component {
};
}

componentDidUpdate(prevProps) {
if (prevProps.isSmallScreenWidth === this.props.isSmallScreenWidth) {
return;
}

// eslint-disable-next-line react/no-did-update-set-state
this.setState({
defaultStatus: Navigation.getDefaultDrawerState(this.props.isSmallScreenWidth),
});
}

render() {
const content = (
<Drawer.Navigator
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
25 changes: 0 additions & 25 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import ONYXKEYS from '../../ONYXKEYS';
import linkingConfig from './linkingConfig';
import navigationRef from './navigationRef';

let resolveNavigationIsReadyPromise;
let navigationIsReadyPromise = new Promise((resolve) => {
resolveNavigationIsReadyPromise = resolve;
});

let isLoggedIn = false;
Onyx.connect({
key: ONYXKEYS.SESSION,
Expand Down Expand Up @@ -191,23 +186,6 @@ function isActiveRoute(routePath) {
return getActiveRoute().substring(1) === routePath;
}

/**
* @returns {Promise}
*/
function isNavigationReady() {
return navigationIsReadyPromise;
}

function setIsNavigationReady() {
resolveNavigationIsReadyPromise();
}

function resetIsNavigationReady() {
navigationIsReadyPromise = new Promise((resolve) => {
resolveNavigationIsReadyPromise = resolve;
});
}

export default {
canNavigate,
navigate,
Expand All @@ -218,9 +196,6 @@ export default {
closeDrawer,
getDefaultDrawerState,
setDidTapNotification,
isNavigationReady,
setIsNavigationReady,
resetIsNavigationReady,
};

export {
Expand Down
16 changes: 10 additions & 6 deletions src/libs/Navigation/NavigationRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {getPathFromState, NavigationContainer, DefaultTheme} from '@react-naviga
import * as Navigation from './Navigation';
import linkingConfig from './linkingConfig';
import AppNavigator from './AppNavigator';
import * as App from '../actions/App';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import Log from '../Log';
import colors from '../../styles/colors';
Expand All @@ -31,6 +30,10 @@ class NavigationRoot extends Component {
constructor(props) {
super(props);

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

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

Expand All @@ -43,15 +46,16 @@ class NavigationRoot extends Component {
return;
}

const path = getPathFromState(state, linkingConfig.config);
const currentPath = getPathFromState(state, linkingConfig.config);

// Don't log the route transitions from OldDot because they contain authTokens
if (path.includes('/transition')) {
if (currentPath.includes('/transition')) {
Log.info('Navigating from transition link from OldDot using short lived authToken');
} else {
Log.info('Navigating to route', false, {path});
Log.info('Navigating to route', false, {path: currentPath});
}
App.setCurrentURL(path);

this.setState({currentPath});
}

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

0 comments on commit 463dc8d

Please sign in to comment.