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

[No QA]Enable an experimental Onyx mode for Guides on login #22902

Merged
merged 3 commits into from
Jul 14, 2023
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
10 changes: 10 additions & 0 deletions src/libs/PolicyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ function isExpensifyTeam(email) {
return emailDomain === CONST.EXPENSIFY_PARTNER_NAME || emailDomain === CONST.EMAIL.GUIDES_DOMAIN;
}

/**
* @param {string} email
* @returns {boolean}
*/
function isExpensifyGuideTeam(email) {
const emailDomain = Str.extractEmailDomain(email);
return emailDomain === CONST.EMAIL.GUIDES_DOMAIN;
}

/**
* Checks if the current user is an admin of the policy.
*
Expand Down Expand Up @@ -132,6 +141,7 @@ export {
getPolicyBrickRoadIndicatorStatus,
shouldShowPolicy,
isExpensifyTeam,
isExpensifyGuideTeam,
isPolicyAdmin,
getClientPolicyMemberEmailsToAccountIDs,
};
15 changes: 15 additions & 0 deletions src/pages/signin/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import DotIndicatorMessage from '../../components/DotIndicatorMessage';
import * as CloseAccount from '../../libs/actions/CloseAccount';
import CONST from '../../CONST';
import isInputAutoFilled from '../../libs/isInputAutoFilled';
import * as PolicyUtils from '../../libs/PolicyUtils';
import Log from '../../libs/Log';

const propTypes = {
/** Should we dismiss the keyboard when transitioning away from the page? */
Expand Down Expand Up @@ -65,6 +67,13 @@ const defaultProps = {
blurOnSubmit: false,
};

/**
* Enables experimental "memory only keys" mode in Onyx
*/
const setEnableMemoryOnlyKeys = () => {
window.enableMemoryOnlyKeys();
};

function LoginForm(props) {
const input = useRef();
const [login, setLogin] = useState('');
Expand Down Expand Up @@ -125,6 +134,12 @@ function LoginForm(props) {
return;
}

// If the user has entered a guide email, then we are going to enable an experimental Onyx mode to help with performance
if (PolicyUtils.isExpensifyGuideTeam(loginTrim)) {
Log.info('Detected guide email in login field, setting memory only keys.');
setEnableMemoryOnlyKeys();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know if it could cause a problem to call window.enableMemoryOnlyKeys() twice? I'm thinking about if the login fails and then the guide tries again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not think so from reading the code

}

setFormError(null);

// Check if this login has an account associated with it or not
Expand Down