Skip to content

Commit

Permalink
Merge pull request #48846 from Expensify/cmartins-sortChatsByDate
Browse files Browse the repository at this point in the history
Sort chats by descending date
  • Loading branch information
srikarparsi authored Sep 9, 2024
2 parents fc30202 + 651ebf6 commit 37749d3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function getSections(type: SearchDataTypes, status: SearchStatus, data: OnyxType

function getSortedSections(type: SearchDataTypes, status: SearchStatus, data: ListItemDataType<typeof type, typeof status>, sortBy?: SearchColumnType, sortOrder?: SortOrder) {
if (type === CONST.SEARCH.DATA_TYPES.CHAT) {
return data;
return getSortedReportActionData(data as ReportActionListItemType[]);
}
return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getSortedTransactionData(data as TransactionListItemType[], sortBy, sortOrder) : getSortedReportData(data as ReportListItemType[]);
}
Expand Down Expand Up @@ -361,6 +361,19 @@ function getSortedReportData(data: ReportListItemType[]) {
});
}

function getSortedReportActionData(data: ReportActionListItemType[]) {
return data.sort((a, b) => {
const aValue = a?.created;
const bValue = b?.created;

if (aValue === undefined || bValue === undefined) {
return 0;
}

return bValue.toLowerCase().localeCompare(aValue);
});
}

function getCurrentSearchParams() {
const rootState = navigationRef.getRootState() as State<RootStackParamList>;

Expand Down

0 comments on commit 37749d3

Please sign in to comment.