-
Notifications
You must be signed in to change notification settings - Fork 3.7k
perf: calculate chat tab brick road based on derived value #61376
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
a25e799
3c53dea
38c86aa
505f4eb
2b4a4e6
0409460
3dbf452
a02f0e5
1426552
70ee8ea
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -73,9 +73,13 @@ export default createOnyxDerivedValueConfig({ | |||||
| dataToIterate = prepareReportKeys(updates); | ||||||
| recentlyUpdated = updates; | ||||||
| } else if (!!transactionsUpdates || !!transactionViolationsUpdates) { | ||||||
| let transactionReportIds: string[] = []; | ||||||
|
Contributor
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.
Suggested change
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. I'll update it with one of the following PRs, thanks |
||||||
| if (transactionsUpdates) { | ||||||
| transactionReportIds = Object.values(transactionsUpdates).map((transaction) => `${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`); | ||||||
| } | ||||||
| // if transactions are updated, they might not be directly related to the reports yet (e.g. transaction is optimistically created) | ||||||
| // so we use report keys that were updated before to recompute the reports | ||||||
| const recentReportKeys = prepareReportKeys(recentlyUpdated); | ||||||
| const recentReportKeys = prepareReportKeys([...recentlyUpdated, ...transactionReportIds]); | ||||||
| dataToIterate = recentReportKeys; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,12 +29,12 @@ function WorkspaceSwitcherPage() { | |
| const {translate} = useLocalize(); | ||
| const {activeWorkspaceID} = useActiveWorkspace(); | ||
|
|
||
| const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); | ||
| const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS); | ||
| const [policies, fetchStatus] = useOnyx(ONYXKEYS.COLLECTION.POLICY); | ||
| const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email}); | ||
| const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); | ||
| const brickRoadsForPolicies = useMemo(() => getWorkspacesBrickRoads(reports, policies, reportActions), [reports, policies, reportActions]); | ||
| const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); | ||
| const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {canBeMissing: true}); | ||
| const [policies, fetchStatus] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); | ||
| const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email, canBeMissing: true}); | ||
| const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); | ||
|
Comment on lines
+35
to
+36
Contributor
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. can these be missing really?
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. This property is here for a while now but I still find it super confusing. Out of curiosity I just checked the codebase and this key is used 4 times with |
||
| const brickRoadsForPolicies = useMemo(() => getWorkspacesBrickRoads(reports, policies), [reports, policies]); | ||
| const unreadStatusesForPolicies = useMemo(() => getWorkspacesUnreadStatuses(reports, reportActions), [reports, reportActions]); | ||
| const shouldShowLoadingIndicator = isLoadingApp && !isOffline; | ||
|
|
||
|
|
||
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 function seems to share the same logic that is used to determine GBR/RBR status for a report in a derived value, so it is safe to simply check the brick road status directly instead of computing it