Skip to content

Commit aa1db35

Browse files
authored
Merge pull request #89051 from callstack-internal/perf/remove-report-attributes-selector
2 parents c8f00cf + 8941628 commit aa1db35

6 files changed

Lines changed: 7 additions & 10 deletions

File tree

src/pages/EditReportFieldPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {reportByIDsSelector} from '@selectors/Attributes';
1+
import reportByIDsSelector from '@selectors/Attributes';
22
import {Str} from 'expensify-common';
33
import React, {useCallback} from 'react';
44
import type {OnyxEntry} from 'react-native-onyx';

src/pages/Search/SearchMoneyRequestReportPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import {clearDeleteTransactionNavigateBackUrl, createTransactionThreadReport, op
4949
import CONST from '@src/CONST';
5050
import ONYXKEYS from '@src/ONYXKEYS';
5151
import SCREENS from '@src/SCREENS';
52-
import {reportByIDsSelector} from '@src/selectors/Attributes';
52+
import reportByIDsSelector from '@src/selectors/Attributes';
5353
import type {ReportAttributesDerivedValue, Transaction, TransactionViolations} from '@src/types/onyx';
5454

5555
type SearchMoneyRequestPageProps =

src/pages/inbox/HeaderView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import useLocalize from '@hooks/useLocalize';
2929
import useOnyx from '@hooks/useOnyx';
3030
import useParentReportAction from '@hooks/useParentReportAction';
3131
import usePolicy from '@hooks/usePolicy';
32+
import useReportAttributes from '@hooks/useReportAttributes';
3233
import useReportIsArchived from '@hooks/useReportIsArchived';
3334
import useResponsiveLayout from '@hooks/useResponsiveLayout';
3435
import useSubscriptionPlan from '@hooks/useSubscriptionPlan';
@@ -85,7 +86,6 @@ import {callFunctionIfActionIsAllowed} from '@userActions/Session';
8586
import CONST from '@src/CONST';
8687
import ONYXKEYS from '@src/ONYXKEYS';
8788
import SCREENS from '@src/SCREENS';
88-
import reportsSelector from '@src/selectors/Attributes';
8989
import {isEmptyObject} from '@src/types/utils/EmptyObject';
9090

9191
type HeaderViewProps = {
@@ -117,7 +117,7 @@ function HeaderView({onNavigationMenuButtonClicked, reportID}: HeaderViewProps)
117117
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`);
118118
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID}`, {selector: pendingChatMembersSelector});
119119
const isReportArchived = isArchivedReport(reportNameValuePairs);
120-
const [reportAttributes] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {selector: reportsSelector});
120+
const reportAttributes = useReportAttributes();
121121
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
122122
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
123123

src/pages/inbox/ReportHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {getReportOfflinePendingActionAndErrors, isInvoiceReport, isMoneyRequestR
1616
import ONYXKEYS from '@src/ONYXKEYS';
1717
import type {Route} from '@src/ROUTES';
1818
import SCREENS from '@src/SCREENS';
19-
import {reportByIDsSelector} from '@src/selectors/Attributes';
19+
import reportByIDsSelector from '@src/selectors/Attributes';
2020
import type * as OnyxTypes from '@src/types/onyx';
2121
import HeaderView from './HeaderView';
2222

src/selectors/Attributes.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import type {OnyxEntry} from 'react-native-onyx';
22
import type {ReportAttributesDerivedValue} from '@src/types/onyx';
33
import type {ReportAttributes} from '@src/types/onyx/DerivedValues';
44

5-
const reportsSelector = (attributes: OnyxEntry<ReportAttributesDerivedValue>) => attributes?.reports;
6-
75
const reportByIDsSelector = (reportIDs: string[]) => (attributes: OnyxEntry<ReportAttributesDerivedValue>) =>
86
reportIDs.reduce(
97
(acc, reportID) => {
@@ -16,5 +14,4 @@ const reportByIDsSelector = (reportIDs: string[]) => (attributes: OnyxEntry<Repo
1614
{} as Record<string, ReportAttributes>,
1715
);
1816

19-
export {reportByIDsSelector};
20-
export default reportsSelector;
17+
export default reportByIDsSelector;

tests/unit/AttributesSelectorTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {reportByIDsSelector} from '@selectors/Attributes';
1+
import reportByIDsSelector from '@selectors/Attributes';
22
import type {OnyxEntry} from 'react-native-onyx';
33
import type {ReportAttributes, ReportAttributesDerivedValue} from '@src/types/onyx/DerivedValues';
44

0 commit comments

Comments
 (0)