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 3 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
13 changes: 13 additions & 0 deletions src/libs/Environment/Environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Config from 'react-native-config';
import lodashGet from 'lodash/get';
import CONST from '../../CONST';
import getEnvironment from './getEnvironment';

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 new Promise(resolve => resolve(false));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can simply be

Suggested change
return new Promise(resolve => resolve(false));
return Promise.resolve(false);

Copy link
Contributor

Choose a reason for hiding this comment

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

You'll have to double-check that it works, but I think it does according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve

}

export default {
isBetaBuild,
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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
Expand All @@ -11,6 +11,4 @@ function getEnvironment() {
return new Promise(resolve => resolve(lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV)));
Copy link
Contributor

Choose a reason for hiding this comment

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

These could also use a more simple return Promise.resolve()

}

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/index';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import betaChecker from '../betaChecker/index';
import betaChecker from '../betaChecker';

No need for that. The modules are smart enough to figure it out

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