-
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
[Fix #21022] Improve performance by reducing re-renders SidebarLinks #21406
[Fix #21022] Improve performance by reducing re-renders SidebarLinks #21406
Conversation
There isn't any case where the current active report wouldn't be in the list of reports
cc @0xmiroslav It should have been assigned to you. |
Please also update unit tests |
Sorry, what do you mean by that @venture1981 |
…f/21022-sidebarlinks-performance
@hannojg could we get back to this one soon? thanks 🙇 |
@hannojg is this ready for review? |
No not yet, sorry, the tests are still failing. Working on it right now |
@mountiny is it possible that something broke during merge? @0xmiroslav are you on the latest version of the perf branch? |
Above video is from
vs |
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.43-0 🚀
|
@hannojg it is possible |
This PR has caused a regression:
@hannojg @fedirjh are you around to help fix this deploy blocker? |
* @returns {Object} | ||
*/ | ||
function getParentReportAction(report) { | ||
function getParentReportAction(report, allReportActionsParam = {}) { |
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 default is causing the deploy blocker here: #23202
If allReportActionsParam
is not passed, it has value {}
which is truthy, so we never use allReportActions
. The allReportActionsParam || allReportActions
doesn't work as intended.
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 you for quickly fixing this!!
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 for the fix
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.43-0 🚀
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.3.44-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.43-7 🚀
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.44-2 🚀
|
withOnyx({ | ||
chatReports: { | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
selector: chatReportSelector, |
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 a "regression"? Without the use of the selector we used to pass the reports objects as is in Onyx. Then we mutated those objects here
Lines 109 to 110 in bba0eb2
// eslint-disable-next-line no-param-reassign | |
report.displayName = ReportUtils.getReportName(report); |
displayName
to each report. If you try to access report.displayName
from anywhere in the App you'd be able to (because we modified the onyx data).
Now, we are using a selector and we are returning a copy of Onyx data, we are mutating a clone and not the onyx data. If we try to access report.displayName
from anywhere outside the Sidebar we won't get a result which in turn caused this issue #23348.
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.
Wow great catch! But at the same time I have to say that how it was working before is very dirty and we should find a different solution for 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.
I see that the proposal proposes a clean way, good job 💪
@@ -253,6 +258,7 @@ describe('Sidebar', () => { | |||
); | |||
}); | |||
|
|||
// NOTE: This is also for #focus mode, should we move this test block? |
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 am not sure what the original intention here was. Maybe @tgolen can remember. This comment stuck out to me as pretty confusing and something we should fix.
context: Working on a PR and encountered a failing test with this title:
Sidebar › in default (most recent) mode › all combinations of isArchived, isUserCreatedPolicyRoom, hasAddWorkspaceError, isUnread, isPinned, hasDraft › the booleans true,false,false,true,false,false
But when I look at the lines of code it's referencing I see that we are not testing "most recent" but "focus" mode.
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 test also confuses me if the intention is that we should be testing "Most recent" mode.
If we are trying to see that a report is in the "Most recent" list then most all reports will be in the list.
Or at least doesn't seem dependent on the arguments we are passing.
isArchived, isUserCreatedPolicyRoom, hasAddWorkspaceError, isUnread, isPinned, hasDraft
All of those will would show in "Most recent" (all other things about the report being "normal")
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.
Ok after reviewing the two blocks - I have determined they are identical and we should be able to remove this...
I don't think this was intended to be put here and it's not logical to test.
Details
Improve the performance by reducing unnecessary re-renders of the
SidebarLinks
component.Fixed Issues
$ #21022
PROPOSAL: #21022 (comment)
Tests
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 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
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)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
Android