App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2021-09-15] Language getting automatically set to English while signing in

Open thesahindia opened this issue 5 years ago • 30 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Your language should be set to Spanish
  2. Go to signin page
  3. Enter any email address or phone number
  4. Try to go back to the signin page by clicking on the link below
  5. Language will be set to English

Expected Result:

Language should not change

Actual Result:

Capture

image

Workaround:

No, Spanish Users might find it hard to navigate.

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number: Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation Expensify/Expensify Issue URL:

View all open jobs on Upwork

thesahindia avatar Aug 09 '21 11:08 thesahindia

Triggered auto assignment to @sonialiap (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

MelvinBot avatar Aug 09 '21 11:08 MelvinBot

Proposal

We need to preserve the locale inside restartSignin function

I can do this by connecting to Onyx for current locale and use this block of code inside restartSignin function

const preferredLocale = currentPreferredLocale;
Onyx.clear().then(() => {
if (preferredLocale) {
Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, preferredLocale);
}
});

thesahindia avatar Aug 09 '21 11:08 thesahindia

Triggered auto assignment to @deetergp (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Aug 10 '21 14:08 MelvinBot

Triggered auto assignment to @arielgreen (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Aug 12 '21 20:08 MelvinBot

Definitely something a external contributor can do, and @thesahindia's proposal sounds good.

deetergp avatar Aug 12 '21 21:08 deetergp

https://www.upwork.com/jobs/~01f7d2db5bd805d8ca

arielgreen avatar Aug 13 '21 22:08 arielgreen

Triggered auto assignment to @tgolen (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar Aug 13 '21 22:08 MelvinBot

@tgolen can you review @thesahindia's proposal?

@thesahindia please also be sure to apply to the Upwork job here.

arielgreen avatar Aug 13 '21 22:08 arielgreen

@arielgreen Submitted the proposal :smile:

thesahindia avatar Aug 14 '21 10:08 thesahindia

I would like to request some changes to your proposal to increase the quality of the code.

I would suggest refactoring this code slightly so that there is only one method in the entire codebase in actions/Session.js which calls Onyx.clear() and it would be a place to handle all of the "need to keep this after clearing Onyx". We are currently only doing this properly in redirectToSignIn() by saving the local and the active clients key.

tgolen avatar Aug 16 '21 16:08 tgolen

@tgolen Hi, I want to know if it'd be a bad idea to just use redirectToSignIn instead of restartSignin since redirectToSignIn is handling this situation in a better way.

https://github.com/Expensify/App/blob/69ee2fe21bf825318a9e717096293aedc51bda4a/src/libs/actions/SignInRedirect.js#L28-L34 Here it says that If we move this function to Session.js then it can cause circular dependency. So, maybe moving the logic to Session.js is not a good idea. Let me know your thoughts.

thesahindia avatar Aug 16 '21 17:08 thesahindia

Yeah, I'd be fine with getting rid of restartSignin completely. Good suggestion! I understand about the circular dependency. It is OK to stay in its own file like that.

With that then, I think it's a complete proposal and I give the 🟢 to be hired for this @arielgreen.

tgolen avatar Aug 18 '21 13:08 tgolen

@thesahindia just sent over an offer! I also raised the price to include the bonus you'll receive for proposing AND fixing this.

arielgreen avatar Aug 19 '21 17:08 arielgreen

Thanks @arielgreen, I have accepted the offer!

thesahindia avatar Aug 19 '21 18:08 thesahindia

@tgolen I have one last query about the use of currentURL inside src/libs/actions/SignInRedirect.js . We are using it here only. https://github.com/Expensify/App/blob/e5957e1ffff7e111a459b05643bac18ffab20619/src/libs/actions/SignInRedirect.js#L41-L43

And then there's no use case of it. However, on the login screen the currentURL will not be set to any value and will fail this condition. We can fix this by giving it a default value of "/" or we can just remove currentURL from the file as I don't see any other use case of it.

Let me know what should be done here. Thanks!

Correction: Using a default value will not fix it as it's being set to the value of null .

thesahindia avatar Aug 19 '21 23:08 thesahindia

It's entirely possible that currentURL can be removed completely. It was added in this PR to fix this GH. I think we need to be a little bit careful here because exitTo is still used in the VALIDATE_CODE_URL but it's used as a query parameter now as opposed to be part of the path. However, the VALIDATE_CODE_URL isn't used to construct a "new expensify" URL, it's used to construct a URL pointing to expensify.com.

So, I still think we are pretty safe to remove currentURL from this file, but you might want to double-check my investigation.

tgolen avatar Aug 20 '21 15:08 tgolen

In fact, I really don't like that VALIDATE_CODE_URL lives in ROUTES.js since it isn't related to a route for New Expensify. Since it's only referenced once, I would just move the logic from ROUTES.js into App.js where it was being referenced. Would you mind cleaning that up?

tgolen avatar Aug 20 '21 15:08 tgolen

Sure, openSignedInLink will look like this after the clean-up.

function openSignedInLink(url = '') {
     API.GetAccountValidateCode().then((response) => {
     const exitToURL = url ? `exitTo=${url}` : '';
     const validateCodeUrl = `v/${currentUserAccountID}/${response.validateCode}${exitToURL}`;
     Linking.openURL(CONFIG.EXPENSIFY.URL_EXPENSIFY_COM + validateCodeUrl);
     });
}

thesahindia avatar Aug 20 '21 19:08 thesahindia

Sure, openSignedInLink will look like this after the clean-up.

function openSignedInLink(url = '') {
     API.GetAccountValidateCode().then((response) => {
     const exitToURL = url ? `exitTo=${url}` : '';
     const validateCodeUrl = `v/${currentUserAccountID}/${response.validateCode}${exitToURL}`;
     Linking.openURL(CONFIG.EXPENSIFY.URL_EXPENSIFY_COM + validateCodeUrl);
     });
}

Beware, This might be not working in Safari Mobile. Linking.openURL does not work here in the Async way. Please test it.

parasharrajat avatar Aug 20 '21 19:08 parasharrajat

Oh, if this might break something then I think it's better to just leave it as it is?

thesahindia avatar Aug 20 '21 20:08 thesahindia