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

/**
* Returns a promise that resolves with the current environment string value
Expand All @@ -13,4 +14,5 @@ function getEnvironment() {

export default {
getEnvironment,
isDevelopment,
};
2 changes: 2 additions & 0 deletions src/libs/Environment/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import lodashGet from 'lodash/get';
import Config from 'react-native-config';
import betaChecker from './betaChecker';
import CONST from '../../CONST';
import isDevelopment from './isDevelopment';

let environment = null;

Expand Down Expand Up @@ -33,4 +34,5 @@ function getEnvironment() {

export default {
getEnvironment,
isDevelopment,
};
12 changes: 12 additions & 0 deletions src/libs/Environment/isDevelopment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import lodashGet from 'lodash/get';
Copy link
Contributor

Choose a reason for hiding this comment

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

I was trying to figure out why this was in it's own file, and then it dawned on me why you did this (and I totally see the logic). I'm not sure it's what we want though. This doesn't really fit our cross-platform pattern because there is a cross-platform module (Environment) that is sharing non-platform specific methods (isDevelopment).

I think rather we should have Environment be non-platform specific and then making only the pieces that need to be platform-specific (getEnvironment in this case) would be split into their platform files.

I hope that makes sense?

import Config from 'react-native-config';
import CONST from '../../CONST';

/**
* Determine if we are in development or not. This method can be synchronous (as opposed to getEnvironment),
* because getEnvironment needs to check betas for native, which is async.
* @return {boolean}
*/
export default function isDevelopment() {
return lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.DEV;
}
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 Environment from './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 Environment.isDevelopment() || _.contains(betas, CONST.BETAS.ALL);
}

/**
Expand Down