perf: remove useLastAccessedReportID hook and call findLastAccessedReport only when needed#44955
Conversation
43db35d to
23574ab
Compare
|
@ikevin127 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] |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
src/hooks/useLastAccessedReportID.ts
Outdated
| * @param skip - Whether to skip the calculation of last accessed report ID | ||
| */ | ||
| export default function useLastAccessedReportID(shouldOpenOnAdminRoom: boolean) { | ||
| export default function useLastAccessedReportID(shouldOpenOnAdminRoom: boolean, skip: boolean) { |
There was a problem hiding this comment.
Rather than adding a skip boolean param in a hook, let's just call ReportUtils.findLastAccessedReport in a useEffect? The reason I suggest that is because when consuming a hook, I'd expect it to re-render the consuming component every time the return value changes, which wouldn't be the case here.
When I added this hook it was used in both AuthScreens and ReportScreen, but it looks like the usage in AuthScreens was removed sometime last week
There was a problem hiding this comment.
Something like what @fabioh8010 suggested here, except removing the hook entirely in favor of just a useEffect
There was a problem hiding this comment.
@roryabraham of course I can use the approach from this PR, but I need to ask @fabioh8010 if he is okay with that, as I would need to copy some of his code to this PR.
There was a problem hiding this comment.
Sure @kosmydel please use everything you may need from my PR, I was exploring an improvement last week but didn't have time to go back to it.
There was a problem hiding this comment.
Thank you @fabioh8010! I've added some of the changes from your PR.
useLastAccessedReportID hook and call findLastAccessedReport only when needed
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / Safari *web.movMacOS: Desktop |
ikevin127
left a comment
There was a problem hiding this comment.
LGTM, tests well in all cases and removed calling findLastAccessedReport when not needed 🚀
|
✋ 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/roryabraham in version: 9.0.6-0 🚀
|
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.0.6-0 🚀
|
|
@kavimuru I think so yes |
|
🚀 Cherry-picked to staging by https://github.com/Julesssss in version: 9.0.6-1 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
|
🚀 Cherry-picked to staging by https://github.com/Julesssss in version: 9.0.6-1 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
|
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.6-8 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.7-8 🚀
|
|
FYI, This caused this regression and was partially reverted in PR #45224 and then corrected in PR #45494. More details in #45494 (comment) |
Details
We should calculate the
lastAccessedReportIDonly when needed, that means only once, and only whenroute.params.reportIDis empty (code). This value is used to determine which chat we should show to the user when the user accesses the website withoutreportIDin the URL.Fixed Issues
$ #44925
PROPOSAL: N/A
Tests
Note
When testing, sometimes the
lastVisitedPathmight be loaded and thefindLastAccessedReportfunction might not be called. To avoid this, you can addreturn undefined;at the beggining of theNavigationRoot->initialStatefunction.Web & mWeb:
Last accessed report
https://staging.new.expensify.com/).New account
Leave room
Other platforms
Offline tests
N/A
QA Steps
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: Native
Android: mWeb Chrome
Screen.Recording.2024-07-08.at.15.19.52.mov
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web2.mov
MacOS: Desktop