-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Migrate deprecated pronouns #39522
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes. Thanks. I didn't understand that requirement previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
src/libs/actions/PersonalDetails.ts
Outdated
@@ -49,7 +49,7 @@ Onyx.connect({ | |||
callback: (val) => (privatePersonalDetails = val), | |||
}); | |||
|
|||
function updatePronouns(pronouns: string) { | |||
function updatePronouns(pronouns: string, navigate = true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 🚀
|
@@ -70,6 +70,7 @@ function PronounsPage({currentUserPersonalDetails, isLoadingApp = true}: Pronoun | |||
|
|||
const updatePronouns = (selectedPronouns: PronounEntry) => { | |||
PersonalDetails.updatePronouns(selectedPronouns.keyForList === currentPronounsKey ? '' : selectedPronouns?.value ?? ''); | |||
Navigation.goBack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
UpdatePronouns
API with the new pronouns format.Fixed Issues
$ #38969
PROPOSAL: #38969 (comment)
Tests
He / Him / His
in this case)UpdatePronouns
API is triggered to set the correct pronounsOffline tests
NA
QA Steps
NA
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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