-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Network] Language Picker on Login Page call the API unnecessarily & does not behave correctly #4513
Comments
Triggered auto assignment to @cdraeger11 ( |
@cdraeger11 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
This seems another issue with Onyx. I tested the withLocalize HOC that if it's getting correct preferredLocale but its not. LocalePicker only run the |
I'll take a look and post back |
I've found the problem while debugging It can be traced to the 20th second of this video where I follow the steps to reproduce with the deubgger Eexpensify_Locale_Picker_On_Login_Screen_Debugging.mp4
Short version: A network request to save the locale should not be made, because there is no logged in user. The problem comes from the network request that happens as it involves 1. Network request to set localeLines 38 to 41 in 8b10c1c
2. addDefaultValuesToParameters calls redirectToSignInLines 51 to 60 in 8b10c1c
There's no apiToken and so redirectToSignIn is called
3. redirectToSignIn clears storage and resets localeApp/src/libs/actions/SignInRedirect.js Lines 46 to 53 in 8b10c1c
Here currentPreferredLocale is the locale before the update, because connections aren't notified with the new value yetWhen the connections are notified with the updated value this function already runs and preferredLocale is setAnd this later causes the bug where the locale does not get updated |
Oh. Great. Network requests will definitely be removed. Good to know that it fixes the issue. |
Regarding the proposal, you don't have to go through this "Block the API call when Language is selected. To do this we can add a prop offline to the LocalPicker which can then pass to"
Lines 13 to 19 in 8b10c1c
So the same information can be extracted like let currentUserAccountID;
let isLoggedIn = false;
Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (val) => {
currentUserAccountID = lodashGet(val, 'accountID', '');
isLoggedIn = Boolean(lodashGet(val, 'authToken'));
},
}); And then used in function setLocale(locale) {
if (isLoggedIn) {
API.PreferredLocale_Update({name: 'preferredLocale', value: locale});
}
Onyx.merge(ONYXKEYS.NVP_PREFERRED_LOCALE, locale);
} |
Or the request can be skipped simply because there would not be a function setLocale(locale) {
if (currentUserAccountID) {
API.PreferredLocale_Update({name: 'preferredLocale', value: locale});
}
Onyx.merge(ONYXKEYS.NVP_PREFERRED_LOCALE, locale);
} |
@cdraeger11 Still overdue 6 days?! Let's take care of this! |
@cdraeger11 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it! |
Seems like there are some clear ideas here. Gonna move this one along. |
Triggered auto assignment to @jboniface ( |
job posted here |
Triggered auto assignment to @Beamanator ( |
What do you think @Beamanator? |
@parasharrajat would you mind re-posting exactly what the latest proposal is? :D Looks like it went through a few reviews so I just want to be clear what the latest plan is |
Sure.
|
Thanks for confirming and re-posing @parasharrajat - The job is yours! Please submit a PR when you have a chance 👍 |
🚀 Deployed to staging by @Beamanator in version: 1.0.88-3 🚀
|
🚀 Deployed to production by @roryabraham in version: 1.0.90-2 🚀
|
it looks like this should have been closed, right? or is there something still pending on this issue? |
@jboniface Lol, what! I was never hired for this job. 🦀 |
oh whoops, accept it and I'll pay you. I was expecting the new process where we show the "hold for payment" message in the title but this must have deployed before that |
ok i paid it (note: i put it up for 500 because you both reported and solved it). |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
ISSUES
Action Performed:
Expected Result:
Actual Result:
Workaround:
None. UI issue
Platform:
Where is this issue occurring?
Version Number: 1.0.85.0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
login-picker.mp4
Expensify/Expensify Issue URL:
View all open jobs on Upwork
view this job on Upwork
Proposal
App/src/libs/actions/App.js
Line 38 in 8b10c1c
true
.currentUserAccountID
before making the API call as this is only present when the user is logined.The text was updated successfully, but these errors were encountered: