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

Fix Sign in- Language preference doesn't persist when user Signs in with google #26948

Merged
merged 5 commits into from
Sep 26, 2023
Merged
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
10 changes: 8 additions & 2 deletions src/libs/actions/Session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Onyx.connect({
callback: (val) => (credentials = val || {}),
});

let nvpPreferredLocale;
Onyx.connect({
key: ONYXKEYS.NVP_PREFERRED_LOCALE,
callback: (val) => (nvpPreferredLocale = val),
});

/**
* Clears the Onyx store and redirects user to the sign in page
*/
Expand Down Expand Up @@ -244,7 +250,7 @@ function beginSignIn(login) {
*/
function beginAppleSignIn(idToken) {
const {optimisticData, successData, failureData} = signInAttemptState();
API.write('SignInWithApple', {idToken}, {optimisticData, successData, failureData});
API.write('SignInWithApple', {idToken, preferredLocale: nvpPreferredLocale}, {optimisticData, successData, failureData});
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make getting preferredLocale logic consistent with normal sign in.
So for all 3 functions, either pass as param or use static value connected with Onyx.

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 prefer "use static value connected with Onyx" for all of them. Because I don't think the preferredLocale is a part of login form. What do you think? @aimane-chnaif

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated PR and tested in local. Could you preview the PR again? Thanks

}

/**
Expand All @@ -255,7 +261,7 @@ function beginAppleSignIn(idToken) {
*/
function beginGoogleSignIn(token) {
const {optimisticData, successData, failureData} = signInAttemptState();
API.write('SignInWithGoogle', {token}, {optimisticData, successData, failureData});
API.write('SignInWithGoogle', {token, preferredLocale: nvpPreferredLocale}, {optimisticData, successData, failureData});
}

/**
Expand Down
Loading