From 271fe26867cc48358e71ce09469ccef2686876cc Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 14 Jul 2023 11:01:00 -0600 Subject: [PATCH 1/3] Enable an experimental Onyx mode for Guides on login --- src/libs/PolicyUtils.js | 10 ++++++++++ src/pages/signin/LoginForm.js | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js index 22b5d8635f72..cd15ea19a160 100644 --- a/src/libs/PolicyUtils.js +++ b/src/libs/PolicyUtils.js @@ -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. * @@ -132,6 +141,7 @@ export { getPolicyBrickRoadIndicatorStatus, shouldShowPolicy, isExpensifyTeam, + isExpensifyGuideTeam, isPolicyAdmin, getClientPolicyMemberEmailsToAccountIDs, }; diff --git a/src/pages/signin/LoginForm.js b/src/pages/signin/LoginForm.js index e4efb80cc0a1..578910b59c98 100644 --- a/src/pages/signin/LoginForm.js +++ b/src/pages/signin/LoginForm.js @@ -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? */ @@ -94,6 +96,13 @@ function LoginForm(props) { [props.account, props.closeAccount, input, setFormError, setLogin], ); + const setEnableMemoryOnlyKeys = () => { + if (!window) { + return; + } + window.enableMemoryOnlyKeys(); + }; + /** * Check that all the form fields are valid, then trigger the submit callback */ @@ -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(); + } + setFormError(null); // Check if this login has an account associated with it or not From 1f92ef2e547a276a94860244262edb6c682e5aad Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 14 Jul 2023 11:43:58 -0600 Subject: [PATCH 2/3] Remove window check as native is working --- src/pages/signin/LoginForm.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/signin/LoginForm.js b/src/pages/signin/LoginForm.js index 578910b59c98..5d7998f47441 100644 --- a/src/pages/signin/LoginForm.js +++ b/src/pages/signin/LoginForm.js @@ -96,10 +96,10 @@ function LoginForm(props) { [props.account, props.closeAccount, input, setFormError, setLogin], ); + /** + * Enables experimental "memory only keys" mode in Onyx + */ const setEnableMemoryOnlyKeys = () => { - if (!window) { - return; - } window.enableMemoryOnlyKeys(); }; From ea194e976ef6e02daece4a1ed31f932eb15c99e6 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 14 Jul 2023 12:00:48 -0600 Subject: [PATCH 3/3] Move function out of component --- src/pages/signin/LoginForm.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/signin/LoginForm.js b/src/pages/signin/LoginForm.js index 5d7998f47441..88df88155eed 100644 --- a/src/pages/signin/LoginForm.js +++ b/src/pages/signin/LoginForm.js @@ -67,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(''); @@ -96,13 +103,6 @@ function LoginForm(props) { [props.account, props.closeAccount, input, setFormError, setLogin], ); - /** - * Enables experimental "memory only keys" mode in Onyx - */ - const setEnableMemoryOnlyKeys = () => { - window.enableMemoryOnlyKeys(); - }; - /** * Check that all the form fields are valid, then trigger the submit callback */