Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon20000 committed Sep 23, 2023
1 parent ea42990 commit 9c82382
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ function isSidebarLoadedReady() {
return sidebarIsReadyPromise;
}

function compareStringDates(stringA, stringB) {
if (stringA < stringB) {
return -1;
}
if (stringA > stringB) {
return 1;
}
return 0;
}

function setIsSidebarLoadedReady() {
resolveSidebarIsReadyPromise();
}
Expand Down Expand Up @@ -184,21 +194,13 @@ function getOrderedReportIDs(currentReportId, allReportsDict, betas, policies, p
pinnedReports.sort((a, b) => a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()));
outstandingIOUReports.sort((a, b) => b.iouReportAmount - a.iouReportAmount || a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()));
draftReports.sort((a, b) => a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()));
const compareStringDates = (stringA, stringB) => {
if (stringA < stringB) {
return 1;
}
if (stringA > stringB) {
return -1;
}
return 0;
};

if (isInDefaultMode) {
nonArchivedReports.sort(
(a, b) => compareStringDates(a.lastVisibleActionCreated, b.lastVisibleActionCreated) || a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()),
(a, b) => compareStringDates(b.lastVisibleActionCreated, a.lastVisibleActionCreated) || a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()),
);
// For archived reports ensure that most recent reports are at the top by reversing the order
archivedReports.sort((a, b) => compareStringDates(a.lastVisibleActionCreated, b.lastVisibleActionCreated));
archivedReports.sort((a, b) => compareStringDates(b.lastVisibleActionCreated, a.lastVisibleActionCreated));
} else {
nonArchivedReports.sort((a, b) => a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()));
archivedReports.sort((a, b) => a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()));
Expand Down

0 comments on commit 9c82382

Please sign in to comment.