Skip to content

Commit

Permalink
Merge pull request Expensify#47891 from daledah/fix/47296
Browse files Browse the repository at this point in the history
fix: improve performance in open chat finder page
  • Loading branch information
luacmartins authored Aug 27, 2024
2 parents 9dc5b65 + 2aea667 commit 5aaf6d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,7 @@ function getOptions(
}

reportOption.isSelected = isReportSelected(reportOption, selectedOptions);
reportOption.isBold = shouldUseBoldText(reportOption);

if (action === CONST.IOU.ACTION.CATEGORIZE) {
const policyCategories = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${reportOption.policyID}`] ?? {};
Expand All @@ -1984,13 +1985,14 @@ function getOptions(

const personalDetailsOptionsToExclude = [...optionsToExclude, {login: currentUserLogin}];
// Next loop over all personal details removing any that are selectedUsers or recentChats
allPersonalDetailsOptions.forEach((personalDetailOption) => {
for (const personalDetailOption of allPersonalDetailsOptions) {
if (personalDetailsOptionsToExclude.some((optionToExclude) => optionToExclude.login === personalDetailOption.login)) {
return;
continue;
}
personalDetailOption.isBold = shouldUseBoldText(personalDetailOption);

personalDetailsOptions.push(personalDetailOption);
});
}

const currentUserOption = allPersonalDetailsOptions.find((personalDetailsOption) => personalDetailsOption.login === currentUserLogin);

Expand Down
1 change: 1 addition & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ type OptionData = {
amountInputProps?: MoneyRequestAmountInputProps;
tabIndex?: 0 | -1;
isConciergeChat?: boolean;
isBold?: boolean;
} & Report;

type OnyxDataTaskAssigneeChat = {
Expand Down
6 changes: 2 additions & 4 deletions src/pages/ChatFinderPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,14 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa

if (recentReports?.length > 0) {
newSections.push({
data: recentReports.map((report) => {
return {...report, isBold: OptionsListUtils.shouldUseBoldText(report)};
}),
data: recentReports,
shouldShow: true,
});
}

if (localPersonalDetails.length > 0) {
newSections.push({
data: localPersonalDetails.map((personalDetail) => ({...personalDetail, isBold: false})),
data: localPersonalDetails,
shouldShow: true,
});
}
Expand Down

0 comments on commit 5aaf6d7

Please sign in to comment.