Skip to content

Commit 1f4c5d1

Browse files
authored
Merge pull request #42704 from bernhardoj/fix/42627-show-self-dm-at-top
Put self DM at the top of search result
2 parents 2c71339 + 70b5655 commit 1f4c5d1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libs/OptionsListUtils.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,9 @@ function orderOptions(options: ReportUtils.OptionData[], searchValue: string | u
15931593
options,
15941594
[
15951595
(option) => {
1596+
if (option.isSelfDM) {
1597+
return 0;
1598+
}
15961599
if (preferChatroomsOverThreads && option.isThread) {
15971600
return 4;
15981601
}
@@ -1812,13 +1815,18 @@ function getOptions(
18121815

18131816
// Sorting the reports works like this:
18141817
// - Order everything by the last message timestamp (descending)
1818+
// - When searching, self DM is put at the top
18151819
// - All archived reports should remain at the bottom
18161820
const orderedReportOptions = lodashSortBy(filteredReportOptions, (option) => {
18171821
const report = option.item;
18181822
if (option.isArchivedRoom) {
18191823
return CONST.DATE.UNIX_EPOCH;
18201824
}
18211825

1826+
if (searchValue) {
1827+
return [option.isSelfDM, report?.lastVisibleActionCreated];
1828+
}
1829+
18221830
return report?.lastVisibleActionCreated;
18231831
});
18241832
orderedReportOptions.reverse();

0 commit comments

Comments
 (0)