Repository navigation
Migrate deprecated pronouns - #39522
Conversation
|
@ntdiary Some notes before reviewing:
|
| const pronounsKey = currentUserPersonalDetails?.pronouns?.replace(CONST.PRONOUNS.PREFIX, '') ?? ''; | ||
| const pronounsKey = PersonalDetailsUtils.getPronounsKey(currentUserPersonalDetails); | ||
| if (PersonalDetailsUtils.isDeprecatedPronouns(currentUserPersonalDetails)) { | ||
| PersonalDetails.updatePronouns(pronounsKey ? `${CONST.PRONOUNS.PREFIX}${pronounsKey}` : '', false); |
There was a problem hiding this comment.
I like going with solution 2, and I would like to recommend to use an Onyx migration instead of using the profile page to correct the pronouns.
I guess what you mean by "onyx migration" here is:
create a file like PronounsMigration.ts in the src/libs/migrations directory to handle mapping or even calling the updatePronouns API, instead of calling the API only when the user visits the ProfilePage? 🤔
cc @tgolen
There was a problem hiding this comment.
Ah yes. Thanks. I didn't understand that requirement previously.
There was a problem hiding this comment.
Yeah, that's what I meant. Sorry for not being clear! The migration would still make the API request to fix the pronoun on the server.
|
@ntdiary Updated with the Onyx migration approach. |
| }); | ||
|
|
||
| function updatePronouns(pronouns: string) { | ||
| function updatePronouns(pronouns: string, navigate = true) { |
There was a problem hiding this comment.
I'd much rather have the navigation happen outside of this method. Is that possible without too much work? I don't like it when the action files do the redirecting because it makes them much more difficult to reuse like you are having to deal with here. It should be handled in the calling code.
There was a problem hiding this comment.
Yes agree! I moved the navigation out.
| } | ||
|
|
||
| const pronouns = currentUserPersonalDetails.pronouns?.replace(CONST.PRONOUNS.PREFIX, '') ?? ''; | ||
| const isDeprecatedPronouns = !!pronouns && !pronouns.startsWith(CONST.PRONOUNS.PREFIX); |
There was a problem hiding this comment.
I don't quite get why a pronoun starting with __predefined_ would mean it's deprecated. Can you explain why that is the case in a code comment, please?
There was a problem hiding this comment.
Yes this condition is not 100% correct. I changed it to check whether the pronouns is in the latest PRONOUNS_LIST.
| const pronounsKey = Object.entries(CONST.DEPRECATED_PRONOUNS_LIST).find((deprecated) => deprecated[1] === pronouns)?.[0] ?? ''; | ||
| PersonalDetails.updatePronouns(pronounsKey ? `${CONST.PRONOUNS.PREFIX}${pronounsKey}` : '', false); |
There was a problem hiding this comment.
I'm kind of confused about what this code is doing. Can you explain it with a code comment, or change the code to be a little more explanatory?
tgolen
left a comment
There was a problem hiding this comment.
Love it. Those changes are great. Thank you!
Reviewer Checklist
Screenshots/VideosAndroid: Native39522-android-native.mp4Android: mWeb Chrome39522-android-chrome.mp4iOS: NativeN/AiOS: mWeb Safari39522-ios-safari.mp4MacOS: Chrome / Safari39522-web.mp4MacOS: Desktop39522-desktop.mp4 |
ntdiary
left a comment
There was a problem hiding this comment.
Note: this migration only occurs when we launch the app that has logged with an account. If we launch the app first and then login, the migration won't occur. :)
|
Hmm I'm not sure why perf-test is failing here but working fine locally. |
I don't think the perf-tests failure is caused by this PR. It seems that the perf-tests is still not very stable. |
|
I've tried re-running the performance tests, and it's still failing. It looks like the tests completed: but the process fails a little later on because of: @gijoe0295 Could you please double-check that you've updated from |
|
@tgolen Thanks for reminding me. I've merged main and all checks passed. Can you try again? |
|
Looks like that worked! Thanks |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/tgolen in version: 1.4.62-0 🚀
|
1 similar comment
|
🚀 Deployed to staging by https://github.com/tgolen in version: 1.4.62-0 🚀
|
|
🚀 Deployed to staging by https://github.com/tgolen in version: 1.4.62-0 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.4.62-17 🚀
|
|
|
||
| const updatePronouns = (selectedPronouns: PronounEntry) => { | ||
| PersonalDetails.updatePronouns(selectedPronouns.keyForList === currentPronounsKey ? '' : selectedPronouns?.value ?? ''); | ||
| Navigation.goBack(); |
There was a problem hiding this comment.
This caused
We should introduce a ref called isOptionSelected that will be true when we select an option, which will prevent the option from being selected multiple times.
Details
Deprecated pronouns are still being stored in the database. This PR migrates those by calling
UpdatePronounsAPI with the new pronouns format.Fixed Issues
$ #38969
PROPOSAL: #38969 (comment)
Tests
He / Him / Hisin this case)UpdatePronounsAPI is triggered to set the correct pronounsOffline tests
NA
QA Steps
NA
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: mWeb Chrome
Screen.Recording.2024-04-04.at.02.07.28-source.mov
iOS: mWeb Safari
Screen.Recording.2024-04-04.at.02.00.36-source.mov
MacOS: Chrome / Safari
Untitled.mov
custom.mov