1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

refactor: fix sorting features by last seen and created at (#755)

This commit is contained in:
olav 2022-03-01 10:35:20 +01:00 committed by GitHub
parent 2bb069af6b
commit 58667565f2

View File

@ -109,17 +109,19 @@ const sortByLastSeen = (
): IFeatureToggle[] => {
return [...features].sort((a, b) =>
a.lastSeenAt && b.lastSeenAt
? a.lastSeenAt.localeCompare(b.lastSeenAt)
: 0
? b.lastSeenAt.localeCompare(a.lastSeenAt)
: a.lastSeenAt
? -1
: b.lastSeenAt
? 1
: b.createdAt.localeCompare(a.createdAt)
);
};
const sortByCreated = (
features: Readonly<IFeatureToggle[]>
): IFeatureToggle[] => {
return [...features].sort((a, b) =>
new Date(a.createdAt) > new Date(b.createdAt) ? -1 : 1
);
return [...features].sort((a, b) => b.createdAt.localeCompare(a.createdAt));
};
const sortByName = (features: Readonly<IFeatureToggle[]>): IFeatureToggle[] => {