From 1fd6d2e514ec57c0371c6f2964dd1aca8b990c14 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 27 Sep 2024 17:11:42 +0800 Subject: [PATCH] bold all title and don't show last message in search "In" filter page --- .../Search/SearchFiltersChatsSelector.tsx | 4 ++-- src/libs/OptionsListUtils.ts | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/components/Search/SearchFiltersChatsSelector.tsx b/src/components/Search/SearchFiltersChatsSelector.tsx index 689f917fdccf..36b56867b99f 100644 --- a/src/components/Search/SearchFiltersChatsSelector.tsx +++ b/src/components/Search/SearchFiltersChatsSelector.tsx @@ -56,7 +56,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen const selectedOptions = useMemo(() => { return selectedReportIDs.map((id) => { const report = getSelectedOptionData(OptionsListUtils.createOptionFromReport({...reports?.[`${ONYXKEYS.COLLECTION.REPORT}${id}`], reportID: id}, personalDetails)); - const alternateText = OptionsListUtils.getAlternateText(report, {showChatPreviewLine: true}); + const alternateText = OptionsListUtils.getAlternateText(report, {}); return {...report, alternateText}; }); }, [personalDetails, reports, selectedReportIDs]); @@ -65,7 +65,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen if (!areOptionsInitialized || !isScreenTransitionEnd) { return defaultListOptions; } - return OptionsListUtils.getSearchOptions(options); + return OptionsListUtils.getSearchOptions(options, '', undefined, false); }, [areOptionsInitialized, isScreenTransitionEnd, options]); const chatOptions = useMemo(() => { diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 51db5a693f91..b0c48eb37eb7 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -532,9 +532,15 @@ function getAlternateText(option: ReportUtils.OptionData, {showChatPreviewLine = const report = ReportUtils.getReportOrDraftReport(option.reportID); const isAdminRoom = ReportUtils.isAdminRoom(report); const isAnnounceRoom = ReportUtils.isAnnounceRoom(report); + const isGroupChat = ReportUtils.isGroupChat(report); + const isExpenseThread = ReportUtils.isMoneyRequest(report); - if (!!option.isThread || !!option.isMoneyRequestReport) { - return option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'report.noActivityYet'); + if (isExpenseThread || option.isMoneyRequestReport) { + return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'iou.expense'); + } + + if (option.isThread) { + return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'threads.thread'); } if (option.isChatRoom && !isAdminRoom && !isAnnounceRoom) { @@ -546,7 +552,11 @@ function getAlternateText(option: ReportUtils.OptionData, {showChatPreviewLine = } if (option.isTaskReport) { - return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'report.noActivityYet'); + return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'task.task'); + } + + if (isGroupChat) { + return showChatPreviewLine && option.lastMessageText ? option.lastMessageText : Localize.translate(preferredLocale, 'common.group'); } return showChatPreviewLine && option.lastMessageText @@ -2084,7 +2094,7 @@ function getOptions( /** * Build the options for the Search view */ -function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] = []): Options { +function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] = [], isUsedInChatFinder = true): Options { Timing.start(CONST.TIMING.LOAD_SEARCH_OPTIONS); Performance.markStart(CONST.TIMING.LOAD_SEARCH_OPTIONS); const optionList = getOptions(options, { @@ -2094,7 +2104,7 @@ function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] = includeMultipleParticipantReports: true, maxRecentReportsToShow: 0, // Unlimited sortByReportTypeInSearch: true, - showChatPreviewLine: true, + showChatPreviewLine: isUsedInChatFinder, includeP2P: true, forcePolicyNamePreview: true, includeOwnedWorkspaceChats: true, @@ -2102,7 +2112,7 @@ function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] = includeMoneyRequests: true, includeTasks: true, includeSelfDM: true, - shouldBoldTitleByDefault: false, + shouldBoldTitleByDefault: !isUsedInChatFinder, }); Timing.end(CONST.TIMING.LOAD_SEARCH_OPTIONS); Performance.markEnd(CONST.TIMING.LOAD_SEARCH_OPTIONS);