Repository navigation
Pass hasReportActions to openReport (p4) #96864
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,17 @@ function WorkspaceRoomsPage({route}: WorkspaceRoomsPageProps) { | |
| const [betas] = useOnyx(ONYXKEYS.BETAS); | ||
|
|
||
| const [policyReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {selector: policyChatRoomsSelector(policyID, reportNameValuePairs)}); | ||
| const [hasReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, { | ||
| selector: (reportActions) => { | ||
| return policyReports?.reduce( | ||
| (acc, curr) => { | ||
| acc[curr.reportID] = !!reportActions?.[curr.reportID]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For admins opening Workspace > Rooms, Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The selector returns it with the reportID as the index. Invalid review. |
||
| return acc; | ||
| }, | ||
| {} as Record<string, boolean>, | ||
| ); | ||
| }, | ||
| }); | ||
|
|
||
| // The newly created room reportID is stored in Onyx right before navigating back here so its row can play the highlight animation. | ||
| // It is cleared by the create page once the navigation transition ends (see WorkspaceNewRoomPage), so the animation doesn't replay on a later visit. | ||
|
|
@@ -72,7 +83,7 @@ function WorkspaceRoomsPage({route}: WorkspaceRoomsPageProps) { | |
| // Admins open the details RHP directly instead of the room report, so the report is never fetched via ReportScreen. | ||
| // Fetch it here so the RHP has full data (participants, metadata) for Join, Invite and renaming. | ||
| // shouldMarkAsRead is false because the user only views the room details, not the conversation itself. | ||
| openReport({reportID: report.reportID, introSelected, betas, shouldMarkAsRead: false}); | ||
| openReport({reportID: report.reportID, introSelected, betas, shouldMarkAsRead: false, hasReportActions: !!hasReportActions?.[report.reportID]}); | ||
| Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.REPORT_DETAILS.getRoute(report.reportID))); | ||
| return; | ||
| } | ||
|
|
||
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.
❌ PERF-11 (docs)
This
useOnyxsubscribes to the entireREPORT_ACTIONScollection (one of the largest collections in the app) and its selector returns aRecord<string, boolean>mapped across every policy report. Because a selector is used, Onyx runsdeepEqualon this whole map on every report-action change anywhere in the app, and the selector also closes over the large externalpolicyReportsdataset and re-iterates it on each of those unrelated updates — compounding the cost. A mapped/transformed collection output like this is exactly the case PERF-11 warns against: thedeepEqualis expensive and there is no meaningful re-render savings.Instead, subscribe without a selector and build the lookup inline (or read presence per-report where it's needed), so Onyx uses the cheap
shallowEqualon raw references:This avoids the per-report mapped object and the
deepEqualover the full collection.Reviewed at: 6f88da6 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
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 think the deepEqual will be expensive here because it's a simple boolean map.