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

Make cash have all betas enabled when running in development mode #3135

Merged
merged 4 commits into from
May 27, 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 src/components/withEnvironment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Environment from '../libs/Environment';
import {getEnvironment} from '../libs/Environment/Environment';
import CONST from '../CONST';
import getComponentDisplayName from '../libs/getComponentDisplayName';

Expand All @@ -20,7 +20,7 @@ export default function (WrappedComponent) {
}

componentDidMount() {
Environment.getEnvironment()
getEnvironment()
.then((environment) => {
this.setState({environment});
});
Expand Down
18 changes: 18 additions & 0 deletions src/libs/Environment/Environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Config from 'react-native-config';
import lodashGet from 'lodash/get';
import CONST from '../../CONST';
import getEnvironment from './getEnvironment';

/**
* Are we running the app in development?
*
* @return {boolean}
*/
function isDevelopment() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a method doc for the return value.

return lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.DEV;
}

export {
getEnvironment,
isDevelopment,
};
12 changes: 12 additions & 0 deletions src/libs/Environment/betaChecker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* There's no beta build in non native
*
* @returns {Promise}
*/
function isBetaBuild() {
return Promise.resolve(false);
}

export default {
isBetaBuild,
};
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import Config from 'react-native-config';
import lodashGet from 'lodash/get';
import CONST from '../../CONST';
import Config from 'react-native-config';
import CONST from '../../../CONST';

/**
* Returns a promise that resolves with the current environment string value
*
* @returns {Promise}
*/
function getEnvironment() {
return new Promise(resolve => resolve(lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV)));
return Promise.resolve(lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV));
}

export default {
getEnvironment,
};
export default getEnvironment;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import lodashGet from 'lodash/get';
import Config from 'react-native-config';
import betaChecker from './betaChecker';
import CONST from '../../CONST';
import betaChecker from '../betaChecker';
import CONST from '../../../CONST';

let environment = null;

Expand Down Expand Up @@ -31,6 +31,4 @@ function getEnvironment() {
});
}

export default {
getEnvironment,
};
export default getEnvironment;
3 changes: 2 additions & 1 deletion src/libs/Permissions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'underscore';
import Onyx from 'react-native-onyx';
import {isDevelopment} from './Environment/Environment';
import CONST from '../CONST';
import ONYXKEYS from '../ONYXKEYS';

Expand All @@ -14,7 +15,7 @@ Onyx.connect({
* @returns {Boolean}
*/
function canUseAllBetas() {
return _.contains(betas, CONST.BETAS.ALL);
return isDevelopment() || _.contains(betas, CONST.BETAS.ALL);
}

/**
Expand Down