-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
perf: remove useLastAccessedReportID
hook and call findLastAccessedReport
only when needed
#44955
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
*/ | ||
export default function useLastAccessedReportID(shouldOpenOnAdminRoom: boolean) { | ||
export default function useLastAccessedReportID(shouldOpenOnAdminRoom: boolean, skip: boolean) { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like what @fabioh8010 suggested here, except removing the hook entirely in favor of just a useEffect
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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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, 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
lastAccessedReportID
only when needed, that means only once, and only whenroute.params.reportID
is empty (code). This value is used to determine which chat we should show to the user when the user accesses the website withoutreportID
in the URL.Fixed Issues
$ #44925
PROPOSAL: N/A
Tests
Note
When testing, sometimes the
lastVisitedPath
might be loaded and thefindLastAccessedReport
function might not be called. To avoid this, you can addreturn undefined;
at the beggining of theNavigationRoot
->initialState
function.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 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: 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