From 6ec53d4538ea897b68450d2f8ad4e1f6e90a80d9 Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 23 Aug 2024 09:15:32 +0700 Subject: [PATCH 1/2] fix: improve performance in open chat finder page --- src/libs/OptionsListUtils.ts | 8 +++++--- src/libs/ReportUtils.ts | 1 + src/pages/ChatFinderPage/index.tsx | 6 ++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 98274e829001..dd3fd678f2a2 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -2019,6 +2019,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}`] ?? {}; @@ -2038,13 +2039,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 = false; personalDetailsOptions.push(personalDetailOption); - }); + } const currentUserOption = allPersonalDetailsOptions.find((personalDetailsOption) => personalDetailsOption.login === currentUserLogin); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2c4d6d9bc1ed..5c935a8d4739 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -461,6 +461,7 @@ type OptionData = { amountInputProps?: MoneyRequestAmountInputProps; tabIndex?: 0 | -1; isConciergeChat?: boolean; + isBold?: boolean; } & Report; type OnyxDataTaskAssigneeChat = { diff --git a/src/pages/ChatFinderPage/index.tsx b/src/pages/ChatFinderPage/index.tsx index 1246bc156278..11965eb4e459 100644 --- a/src/pages/ChatFinderPage/index.tsx +++ b/src/pages/ChatFinderPage/index.tsx @@ -123,16 +123,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, }); } From 2aea667c59dbbb94e3a03430f43dec5015fb22cb Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 23 Aug 2024 11:23:56 +0700 Subject: [PATCH 2/2] fix: change isBold logic for personalDetails --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index dd3fd678f2a2..0f7914b03c1c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -2043,7 +2043,7 @@ function getOptions( if (personalDetailsOptionsToExclude.some((optionToExclude) => optionToExclude.login === personalDetailOption.login)) { continue; } - personalDetailOption.isBold = false; + personalDetailOption.isBold = shouldUseBoldText(personalDetailOption); personalDetailsOptions.push(personalDetailOption); }