-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[TS migration] Migrate 'PersonalDetailsUtils.js' lib to TypeScript #30169
[TS migration] Migrate 'PersonalDetailsUtils.js' lib to TypeScript #30169
Conversation
src/libs/PersonalDetailsUtils.ts
Outdated
import * as LocalePhoneNumber from './LocalePhoneNumber'; | ||
import * as OnyxTypes from '../types/onyx'; | ||
|
||
type PersonalDetailsList = Record<string, OnyxEntry<OnyxTypes.PersonalDetails>>; |
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.
type PersonalDetailsList = Record<string, OnyxEntry<OnyxTypes.PersonalDetails>>; | |
type PersonalDetailsList = Record<string, OnyxTypes.PersonalDetails | null>; |
In this case would make more sense not using OnyxEntry
internally in this way.
BTW, do you think we can move this PersonalDetailsList
type to src/types/onyx/PersonalDetails.ts
and use it in ONYXKEYS.ts as well?
src/libs/PersonalDetailsUtils.ts
Outdated
type PersonalDetailsList = Record<string, OnyxEntry<OnyxTypes.PersonalDetails>>; | ||
|
||
let personalDetails: OnyxTypes.PersonalDetails[] = []; | ||
let allPersonalDetails: OnyxEntry<Record<string, OnyxTypes.PersonalDetails>> = {}; |
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.
let allPersonalDetails: OnyxEntry<Record<string, OnyxTypes.PersonalDetails>> = {}; | |
let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {}; |
Done! @fabioh8010 |
@BartoszGrajdek LGTM but we have typecheck errors. |
@BartoszGrajdek LGTM, but I think we can remove |
@thesahindia Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@thesahindia bump |
@BartoszGrajdek, please resolve the conflicts. |
Done! @thesahindia :) |
@thesahindia fixed! Thank you for noticing that 🙇🏻 |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2023-12-10.at.10.43.21.PM.movAndroid: mWeb ChromeScreen.Recording.2023-12-10.at.10.52.01.PM.moviOS: NativeScreen.Recording.2023-12-11.at.1.43.28.AM.moviOS: mWeb SafariScreen.Recording.2023-12-10.at.11.37.02.PM.movMacOS: Chrome / SafariScreen.Recording.2023-12-10.at.9.29.41.PM.movMacOS: DesktopScreen.Recording.2023-12-11.at.1.58.15.AM.mov |
We did not find an internal engineer to review this PR, trying to assign a random engineer to #24884 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
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.
Looks good overall!
@@ -30,14 +30,14 @@ function ArchivedReportFooter({report, reportClosedAction, personalDetails = {}} | |||
|
|||
const originalMessage = reportClosedAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED ? reportClosedAction.originalMessage : null; | |||
const archiveReason = originalMessage?.reason ?? CONST.REPORT.ARCHIVE_REASON.DEFAULT; | |||
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails, [report.ownerAccountID, 'displayName']); | |||
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[report?.ownerAccountID ?? '']?.displayName); |
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.
ownerAccountID is of type number. Should this condition default to 0?
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.
Done! 😄
Thank you! A type check test is failing |
@MonilBhavsar done 😄 |
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.
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/MonilBhavsar in version: 1.4.14-0 🚀
|
🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 1.4.14-0 🚀
|
* @param [defaultValue] optional default display name value | ||
*/ | ||
function getDisplayNameOrDefault(displayName?: string, defaultValue = ''): string { | ||
return displayName ?? defaultValue ?? Localize.translateLocal('common.hidden'); |
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.
Did you test this function to ever actually fall back to Localize.translateLocal('common.hidden')
?
??
only checks for undefined
and null
, so '' ??
will always be true.
Therefore, since you pass defaultValue = ''
, the defaultValue ??
check will always be true
, and we'll return the defaultValue
even if it's empty, won't we?
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.4.14-6 🚀
|
Details
Migrate 'PersonalDetailsUtils.js' lib file to TypeScript
Fixed Issues
$ #24884
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
ios.mov
Android
android.mov