diff --git a/src/components/ValidateCode/ValidateCodeModal.js b/src/components/ValidateCode/ValidateCodeModal.js index eabb21eea4a9..ceebc54a47af 100644 --- a/src/components/ValidateCode/ValidateCodeModal.js +++ b/src/components/ValidateCode/ValidateCodeModal.js @@ -39,7 +39,7 @@ const defaultProps = { }; function ValidateCodeModal(props) { - const signInHere = useCallback(() => Session.signInWithValidateCode(props.accountID, props.code, props.preferredLocale), [props.accountID, props.code, props.preferredLocale]); + const signInHere = useCallback(() => Session.signInWithValidateCode(props.accountID, props.code), [props.accountID, props.code]); return ( diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js index b250c35cf664..117a092c3875 100644 --- a/src/libs/actions/Session/index.js +++ b/src/libs/actions/Session/index.js @@ -45,10 +45,10 @@ Onyx.connect({ callback: (val) => (credentials = val || {}), }); -let nvpPreferredLocale; +let preferredLocale; Onyx.connect({ key: ONYXKEYS.NVP_PREFERRED_LOCALE, - callback: (val) => (nvpPreferredLocale = val), + callback: (val) => (preferredLocale = val), }); /** @@ -260,7 +260,7 @@ function beginSignIn(login) { */ function beginAppleSignIn(idToken) { const {optimisticData, successData, failureData} = signInAttemptState(); - API.write('SignInWithApple', {idToken, preferredLocale: nvpPreferredLocale}, {optimisticData, successData, failureData}); + API.write('SignInWithApple', {idToken, preferredLocale}, {optimisticData, successData, failureData}); } /** @@ -271,7 +271,7 @@ function beginAppleSignIn(idToken) { */ function beginGoogleSignIn(token) { const {optimisticData, successData, failureData} = signInAttemptState(); - API.write('SignInWithGoogle', {token, preferredLocale: nvpPreferredLocale}, {optimisticData, successData, failureData}); + API.write('SignInWithGoogle', {token, preferredLocale}, {optimisticData, successData, failureData}); } /** @@ -327,9 +327,8 @@ function signInWithShortLivedAuthToken(email, authToken) { * * @param {String} validateCode 6 digit code required for login * @param {String} [twoFactorAuthCode] - * @param {String} [preferredLocale] Indicates which language to use when the user lands in the app */ -function signIn(validateCode, twoFactorAuthCode, preferredLocale = CONST.LOCALES.DEFAULT) { +function signIn(validateCode, twoFactorAuthCode) { const optimisticData = [ { onyxMethod: Onyx.METHOD.MERGE, @@ -386,7 +385,7 @@ function signIn(validateCode, twoFactorAuthCode, preferredLocale = CONST.LOCALES }); } -function signInWithValidateCode(accountID, code, preferredLocale = CONST.LOCALES.DEFAULT, twoFactorAuthCode = '') { +function signInWithValidateCode(accountID, code, twoFactorAuthCode = '') { // If this is called from the 2fa step, get the validateCode directly from onyx // instead of the one passed from the component state because the state is changing when this method is called. const validateCode = twoFactorAuthCode ? credentials.validateCode : code; @@ -462,8 +461,8 @@ function signInWithValidateCode(accountID, code, preferredLocale = CONST.LOCALES }); } -function signInWithValidateCodeAndNavigate(accountID, validateCode, preferredLocale = CONST.LOCALES.DEFAULT, twoFactorAuthCode = '') { - signInWithValidateCode(accountID, validateCode, preferredLocale, twoFactorAuthCode); +function signInWithValidateCodeAndNavigate(accountID, validateCode, twoFactorAuthCode = '') { + signInWithValidateCode(accountID, validateCode, twoFactorAuthCode); Navigation.navigate(ROUTES.HOME); } diff --git a/src/pages/ValidateLoginPage/index.js b/src/pages/ValidateLoginPage/index.js index 561c8512ca3d..0af978172822 100644 --- a/src/pages/ValidateLoginPage/index.js +++ b/src/pages/ValidateLoginPage/index.js @@ -6,7 +6,6 @@ import {propTypes as validateLinkPropTypes, defaultProps as validateLinkDefaultP import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator'; import ONYXKEYS from '../../ONYXKEYS'; import * as Session from '../../libs/actions/Session'; -import useLocalize from '../../hooks/useLocalize'; import Navigation from '../../libs/Navigation/Navigation'; const propTypes = { @@ -35,8 +34,6 @@ const defaultProps = { }; function ValidateLoginPage(props) { - const {preferredLocale} = useLocalize(); - useEffect(() => { const accountID = lodashGet(props.route.params, 'accountID', ''); const validateCode = lodashGet(props.route.params, 'validateCode', ''); @@ -46,7 +43,7 @@ function ValidateLoginPage(props) { // because we don't want to block the user with the interstitial page. Navigation.goBack(false); } else { - Session.signInWithValidateCodeAndNavigate(accountID, validateCode, preferredLocale); + Session.signInWithValidateCodeAndNavigate(accountID, validateCode); } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/src/pages/ValidateLoginPage/index.website.js b/src/pages/ValidateLoginPage/index.website.js index 323779a7d420..4ac12b3193f3 100644 --- a/src/pages/ValidateLoginPage/index.website.js +++ b/src/pages/ValidateLoginPage/index.website.js @@ -7,7 +7,6 @@ import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndica import ValidateCodeModal from '../../components/ValidateCode/ValidateCodeModal'; import ONYXKEYS from '../../ONYXKEYS'; import * as Session from '../../libs/actions/Session'; -import useLocalize from '../../hooks/useLocalize'; import ExpiredValidateCodeModal from '../../components/ValidateCode/ExpiredValidateCodeModal'; import Navigation from '../../libs/Navigation/Navigation'; import CONST from '../../CONST'; @@ -49,7 +48,6 @@ const defaultProps = { }; function ValidateLoginPage(props) { - const {preferredLocale} = useLocalize(); const login = lodashGet(props, 'credentials.login', null); const autoAuthState = lodashGet(props, 'session.autoAuthState', CONST.AUTO_AUTH_STATE.NOT_STARTED); const accountID = lodashGet(props.route.params, 'accountID', ''); @@ -71,7 +69,7 @@ function ValidateLoginPage(props) { } // The user has initiated the sign in process on the same browser, in another tab. - Session.signInWithValidateCode(accountID, validateCode, preferredLocale); + Session.signInWithValidateCode(accountID, validateCode); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js index 51cb287f9564..c38e4dd3c4dd 100755 --- a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js +++ b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js @@ -51,9 +51,6 @@ const propTypes = { authToken: PropTypes.string, }), - /** Indicates which locale the user currently has selected */ - preferredLocale: PropTypes.string, - /** Information about the network */ network: networkPropTypes.isRequired, @@ -69,7 +66,6 @@ const defaultProps = { session: { authToken: null, }, - preferredLocale: CONST.LOCALES.DEFAULT, }; function BaseValidateCodeForm(props) { @@ -228,11 +224,11 @@ function BaseValidateCodeForm(props) { const accountID = lodashGet(props.credentials, 'accountID'); if (accountID) { - Session.signInWithValidateCode(accountID, validateCode, props.preferredLocale, twoFactorAuthCode); + Session.signInWithValidateCode(accountID, validateCode, twoFactorAuthCode); } else { - Session.signIn(validateCode, twoFactorAuthCode, props.preferredLocale); + Session.signIn(validateCode, twoFactorAuthCode); } - }, [props.account, props.credentials, props.preferredLocale, twoFactorAuthCode, validateCode]); + }, [props.account, props.credentials, twoFactorAuthCode, validateCode]); return ( <> @@ -323,7 +319,6 @@ export default compose( withOnyx({ account: {key: ONYXKEYS.ACCOUNT}, credentials: {key: ONYXKEYS.CREDENTIALS}, - preferredLocale: {key: ONYXKEYS.NVP_PREFERRED_LOCALE}, session: {key: ONYXKEYS.SESSION}, }), withNetwork(),