Skip to content

Commit

Permalink
short-circuit nonArchivedReports sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
kacper-mikolajczak committed Feb 14, 2024
1 parent 76e5b1c commit f0532e0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,11 @@ function getOrderedReportIDs(
if (isInDefaultMode) {
nonArchivedReports.sort((a, b) => {
const compareDates = a?.lastVisibleActionCreated && b?.lastVisibleActionCreated ? compareStringDates(b.lastVisibleActionCreated, a.lastVisibleActionCreated) : 0;
if (compareDates) {
return compareDates;
}
const compareDisplayNames = a?.displayName && b?.displayName ? a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()) : 0;
return compareDates || compareDisplayNames;
return compareDisplayNames;
});
// For archived reports ensure that most recent reports are at the top by reversing the order
archivedReports.sort((a, b) => (a?.lastVisibleActionCreated && b?.lastVisibleActionCreated ? compareStringDates(b.lastVisibleActionCreated, a.lastVisibleActionCreated) : 0));
Expand Down

0 comments on commit f0532e0

Please sign in to comment.