- 
                Notifications
    
You must be signed in to change notification settings  - Fork 3.4k
 
[No QA] [TS migration] Migrate 'PersonalDetails.js' lib to TypeScript #28269
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
[No QA] [TS migration] Migrate 'PersonalDetails.js' lib to TypeScript #28269
Conversation
| const detailsByLogin = _.findWhere(allPersonalDetails, {login: userAccountIDOrLogin}) || {}; | ||
| return detailsByLogin.displayName || userAccountIDOrLogin; | ||
| if (Number.isNaN(accountID)) { | ||
| const detailsByLogin = Object.entries(allPersonalDetails ?? {}).find(([, value]) => value?.login === userAccountIDOrLogin)?.[1]; | 
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.
feels like a good candidate for introducing a global EMPTY_OBJECT to limit the memory footprint. Do you think that's possible?
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 know how much memory we could save by doing this, but looks like an interesting proposal to explore. We also must ensure that object is read only and cannot be mutated.
| 
           I will put this on HOLD until is Expensify/react-native-onyx#353 merged.  | 
    
| type DeleteUserAvatarParams = Record<string, never>; | ||
| 
               | 
          ||
| const parameters: DeleteUserAvatarParams = {}; | ||
| 
               | 
          ||
| API.write('DeleteUserAvatar', parameters, {optimisticData, failureData}); | 
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.
Isn't this enough?
    API.write('DeleteUserAvatar', {}, {optimisticData, failureData});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.
It's part of what we discussed here.
| ]; | ||
| 
               | 
          ||
| API.write('UpdateUserAvatar', {file}, {optimisticData, successData, failureData}); | ||
| type UpdateUserAvatarParams = { | 
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.
It's first time I see types defined inside of a function, I would rather move it outside of the function scope. Wdyt?
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.
It's part of what we discussed here.
| ]; | ||
| API.read('OpenPublicProfilePage', {accountID}, {optimisticData, successData, failureData}); | ||
| 
               | 
          ||
| type OpenPublicProfilePageParams = { | 
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.
Same here
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.
It's part of what we discussed here.
        
          
                src/libs/actions/PersonalDetails.ts
              
                Outdated
          
        
      | }); | ||
| 
               | 
          ||
| let allPersonalDetails; | ||
| let allPersonalDetails: OnyxCollection<OnyxTypes.PersonalDetails> = null; | 
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.
PersonalDetails is not a collection, I think this type is more accurate:
OnyxEntry<Record<string, PersonalDetails>>        
          
                src/libs/actions/PersonalDetails.ts
              
                Outdated
          
        
      | import CONST from '../../CONST'; | ||
| import ONYXKEYS from '../../ONYXKEYS'; | ||
| import ROUTES from '../../ROUTES'; | ||
| import * as OnyxTypes from '../../types/onyx'; | 
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.
NAB: I would import types a bit different:
import PersonalDetails from '../../types/onyx/PersonalDetails';| 
           FYI I will be on vacations starting tomorrow for the next two weeks and will return on Oct 23, so @kubabutkiewicz will replace me on this PR!  | 
    
| 
           @blazejkustra comments are resolved , can you recheck 😄 ?  | 
    
| 
           @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]  | 
    
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.
Please careful check ?? operators when left one is empty string.
| 
               | 
          ||
| let currentUserEmail = ''; | ||
| let currentUserAccountID; | ||
| let currentUserAccountID = -1; | 
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.
Any reason for setting default value here?
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.
It will be set to -1 as default value in connect(), so it's safe to assume that the default value for this variable is also -1.
let currentUserEmail = '';
let currentUserAccountID = -1;
Onyx.connect({
    key: ONYXKEYS.SESSION,
    callback: (val) => {
        currentUserEmail = val?.email ?? '';
        currentUserAccountID = val?.accountID ?? -1;
    },
});
          
 If   | 
    
| 
           Hi @situchan , I've updated the branch against   | 
    
| 
           @fabioh8010 please fix conflict when you get a chance  | 
    
| 
           @situchan Done, please check it again!  | 
    
| 
           @situchan bump!  | 
    
| 
           on it now  | 
    
…b/PersonalDetails
…ify-app into ts/lib/PersonalDetails
          Reviewer Checklist
 Screenshots/VideosAndroid: Nativeandroid-msafari.movAndroid: mWeb Chromedesktop-mchrome.moviOS: Nativeweb-ios.moviOS: mWeb Safariandroid-msafari.movMacOS: Chrome / Safariweb-ios.movMacOS: Desktopdesktop-mchrome.mov | 
    
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.
![]()
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.
Hmm, not sure why engineer is not auto assigned
Reapproving
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.
LGTM
| 
           ✋ 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/cristipaval in version: 1.3.96-0 🚀 
  | 
    
| 
           🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.96-15 🚀 
  | 
    
| 
           🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.97-7 🚀 
  | 
    

Details
Fixed Issues
$ #24909
PROPOSAL: N/A
Tests
General testing in profile page:
Offline tests
Same as above.
QA Steps
Same as above.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)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
Web
Screen.Recording.2023-10-04.at.12.34.55.mov
Screen.Recording.2023-10-04.at.12.35.45.mov
Desktop
Screen.Recording.2023-10-04.at.12.36.29.mov
Mobile Web - Chrome
Screen.Recording.2023-10-04.at.12.38.02.mov
Android
Screen.Recording.2023-10-04.at.12.38.58.mov
Mobile Web - Safari
Screen.Recording.2023-10-04.at.12.39.55.mov
iOS
Screen.Recording.2023-10-04.at.12.40.50.mov