Skip to content

Commit

Permalink
Merge pull request #49835 from bernhardoj/fix/49100-inconsistent-bold…
Browse files Browse the repository at this point in the history
…-behavior

Bold all title and don't show last message in search "In" filter page
  • Loading branch information
luacmartins authored Sep 30, 2024
2 parents decf515 + 1fd6d2e commit a78358f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/Search/SearchFiltersChatsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen
const selectedOptions = useMemo<OptionData[]>(() => {
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]);
Expand All @@ -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(() => {
Expand Down
22 changes: 16 additions & 6 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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, {
Expand All @@ -2094,15 +2104,15 @@ function getSearchOptions(options: OptionList, searchValue = '', betas: Beta[] =
includeMultipleParticipantReports: true,
maxRecentReportsToShow: 0, // Unlimited
sortByReportTypeInSearch: true,
showChatPreviewLine: true,
showChatPreviewLine: isUsedInChatFinder,
includeP2P: true,
forcePolicyNamePreview: true,
includeOwnedWorkspaceChats: true,
includeThreads: true,
includeMoneyRequests: true,
includeTasks: true,
includeSelfDM: true,
shouldBoldTitleByDefault: false,
shouldBoldTitleByDefault: !isUsedInChatFinder,
});
Timing.end(CONST.TIMING.LOAD_SEARCH_OPTIONS);
Performance.markEnd(CONST.TIMING.LOAD_SEARCH_OPTIONS);
Expand Down

0 comments on commit a78358f

Please sign in to comment.