Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put self DM at the top of search result #42704

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,9 @@ function orderOptions(options: ReportUtils.OptionData[], searchValue: string | u
options,
[
(option) => {
if (option.isSelfDM) {
return 0;
}
if (preferChatroomsOverThreads && option.isThread) {
return 4;
}
Expand Down Expand Up @@ -1812,13 +1815,18 @@ function getOptions(

// Sorting the reports works like this:
// - Order everything by the last message timestamp (descending)
// - When searching, self DM is put at the top
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wanted to do this only when user have searched for themselves via their email or display name. But I think it is fine for now.

// - All archived reports should remain at the bottom
const orderedReportOptions = lodashSortBy(filteredReportOptions, (option) => {
const report = option.item;
if (option.isArchivedRoom) {
return CONST.DATE.UNIX_EPOCH;
}

if (searchValue) {
return [option.isSelfDM, report?.lastVisibleActionCreated];
}

return report?.lastVisibleActionCreated;
});
orderedReportOptions.reverse();
Expand Down
Loading