Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version to 1.0.81-7 on staging #4341

Merged
merged 5 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001008106
versionName "1.0.81-6"
versionCode 1001008107
versionName "1.0.81-7"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCash/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.0.81.6</string>
<string>1.0.81.7</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCashTests/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.0.81.6</string>
<string>1.0.81.7</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion 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": "expensify.cash",
"version": "1.0.81-6",
"version": "1.0.81-7",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "Expensify.cash is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
11 changes: 7 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {SafeAreaProvider} from 'react-native-safe-area-context';
import CustomStatusBar from './components/CustomStatusBar';
import ErrorBoundary from './components/ErrorBoundary';
import Expensify from './Expensify';
import {LocaleContextProvider} from './components/withLocalize';

LogBox.ignoreLogs([
// Basically it means that if the app goes in the background and back to foreground on Android,
Expand All @@ -17,10 +18,12 @@ LogBox.ignoreLogs([

const App = () => (
<SafeAreaProvider>
<CustomStatusBar />
<ErrorBoundary errorMessage="E.cash crash caught by error boundary">
<Expensify />
</ErrorBoundary>
<LocaleContextProvider>
<CustomStatusBar />
<ErrorBoundary errorMessage="E.cash crash caught by error boundary">
<Expensify />
</ErrorBoundary>
</LocaleContextProvider>
</SafeAreaProvider>
);

Expand Down
224 changes: 112 additions & 112 deletions src/components/withLocalize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {createContext, forwardRef} from 'react';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import getComponentDisplayName from '../libs/getComponentDisplayName';
Expand All @@ -9,6 +9,8 @@ import {toLocalPhone, fromLocalPhone} from '../libs/LocalePhoneNumber';
import numberFormat from '../libs/numberFormat';
import CONST from '../CONST';

const LocaleContext = createContext(null);

const withLocalizePropTypes = {
/** Returns translated string for given locale and phrase */
translate: PropTypes.func.isRequired,
Expand All @@ -29,124 +31,122 @@ const withLocalizePropTypes = {
fromLocalPhone: PropTypes.func.isRequired,
};

export default (WrappedComponent) => {
const propTypes = {
/** The user's preferred locale e.g. 'en', 'es-ES' */
preferredLocale: PropTypes.string,

/** Passed ref from whatever component is wrapped in the HOC */
forwardedRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({current: PropTypes.instanceOf(React.Component)}),
]),
};

const defaultProps = {
preferredLocale: CONST.DEFAULT_LOCALE,
forwardedRef: undefined,
};

class WithLocalize extends React.Component {
constructor(props) {
super(props);

this.translate = this.translate.bind(this);
this.numberFormat = this.numberFormat.bind(this);
this.timestampToRelative = this.timestampToRelative.bind(this);
this.timestampToDateTime = this.timestampToDateTime.bind(this);
this.fromLocalPhone = this.fromLocalPhone.bind(this);
this.toLocalPhone = this.toLocalPhone.bind(this);
}

/**
* @param {String} phrase
* @param {Object} [variables]
* @returns {String}
*/
translate(phrase, variables) {
return translate(this.props.preferredLocale, phrase, variables);
}

/**
* @param {Number} number
* @param {Intl.NumberFormatOptions} options
* @returns {String}
*/
numberFormat(number, options) {
return numberFormat(this.props.preferredLocale, number, options);
}

/**
* @param {Number} timestamp
* @returns {String}
*/
timestampToRelative(timestamp) {
return DateUtils.timestampToRelative(this.props.preferredLocale, timestamp);
}

/**
* @param {Number} timestamp
* @param {Boolean} [includeTimezone]
* @returns {String}
*/
timestampToDateTime(timestamp, includeTimezone) {
return DateUtils.timestampToDateTime(
this.props.preferredLocale,
timestamp,
includeTimezone,
);
}

/**
* @param {Number} number
* @returns {String}
*/
toLocalPhone(number) {
return toLocalPhone(this.props.preferredLocale, number);
}

/**
* @param {Number} number
* @returns {String}
*/
fromLocalPhone(number) {
return fromLocalPhone(this.props.preferredLocale, number);
}

render() {
return (
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
{...this.props}
ref={this.props.forwardedRef}
translate={this.translate}
numberFormat={this.numberFormat}
timestampToRelative={this.timestampToRelative}
timestampToDateTime={this.timestampToDateTime}
toLocalPhone={this.toLocalPhone}
fromLocalPhone={this.fromLocalPhone}
/>
);
}
const localeProviderPropTypes = {
/** The user's preferred locale e.g. 'en', 'es-ES' */
preferredLocale: PropTypes.string,

/* Actual content wrapped by this component */
children: PropTypes.node.isRequired,
};

const localeProviderDefaultProps = {
preferredLocale: CONST.DEFAULT_LOCALE,
};

class LocaleContextProvider extends React.Component {
constructor(props) {
super(props);

/* The context this component exposes to consumers */
this.translateUtils = {
translate: this.translate.bind(this),
numberFormat: this.numberFormat.bind(this),
timestampToRelative: this.timestampToRelative.bind(this),
timestampToDateTime: this.timestampToDateTime.bind(this),
fromLocalPhone: this.fromLocalPhone.bind(this),
toLocalPhone: this.toLocalPhone.bind(this),
};
}

WithLocalize.propTypes = propTypes;
WithLocalize.defaultProps = defaultProps;
/**
* @param {String} phrase
* @param {Object} [variables]
* @returns {String}
*/
translate(phrase, variables) {
return translate(this.props.preferredLocale, phrase, variables);
}

/**
* @param {Number} number
* @param {Intl.NumberFormatOptions} options
* @returns {String}
*/
numberFormat(number, options) {
return numberFormat(this.props.preferredLocale, number, options);
}

const withForwardedRef = React.forwardRef((props, ref) => (
// eslint-disable-next-line react/jsx-props-no-spreading
<WithLocalize {...props} forwardedRef={ref} />
/**
* @param {Number} timestamp
* @returns {String}
*/
timestampToRelative(timestamp) {
return DateUtils.timestampToRelative(this.props.preferredLocale, timestamp);
}

/**
* @param {Number} timestamp
* @param {Boolean} [includeTimezone]
* @returns {String}
*/
timestampToDateTime(timestamp, includeTimezone) {
return DateUtils.timestampToDateTime(
this.props.preferredLocale,
timestamp,
includeTimezone,
);
}

/**
* @param {Number} number
* @returns {String}
*/
toLocalPhone(number) {
return toLocalPhone(this.props.preferredLocale, number);
}

/**
* @param {Number} number
* @returns {String}
*/
fromLocalPhone(number) {
return fromLocalPhone(this.props.preferredLocale, number);
}

render() {
return (
<LocaleContext.Provider value={this.translateUtils}>
{this.props.children}
</LocaleContext.Provider>
);
}
}

LocaleContextProvider.propTypes = localeProviderPropTypes;
LocaleContextProvider.defaultProps = localeProviderDefaultProps;

const Provider = withOnyx({
preferredLocale: {
key: ONYXKEYS.NVP_PREFERRED_LOCALE,
},
})(LocaleContextProvider);

Provider.displayName = 'withOnyx(LocaleContextProvider)';

export default function withLocalize(WrappedComponent) {
const WithLocalize = forwardRef((props, ref) => (
<LocaleContext.Consumer>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
{ translateUtils => <WrappedComponent {...translateUtils} {...props} ref={ref} />}
</LocaleContext.Consumer>
));

withForwardedRef.displayName = `withLocalize(${getComponentDisplayName(WrappedComponent)})`;
WithLocalize.displayName = `withLocalize(${getComponentDisplayName(WrappedComponent)})`;

return withOnyx({
preferredLocale: {
key: ONYXKEYS.NVP_PREFERRED_LOCALE,
},
})(withForwardedRef);
};
return WithLocalize;
}

export {
withLocalizePropTypes,
Provider as LocaleContextProvider,
};