Merge pull request #40 from gurucomputing/34-last-seen-sort-works-in-wrong-direction

fix sort based on lastseen
This commit is contained in:
routerino 2022-08-13 21:04:05 +10:00 committed by GitHub
commit 60bd0bed4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -286,6 +286,10 @@
});
await headscaleDeviceResponse.json().then((data) => {
// flip the sort direction if based on lastSeen
if(sortKey == "lastSeen") {
sortDirection == 'ascending' ? sortDirection = 'descending' : sortDirection = 'ascending';
}
if (sortDirection == 'ascending') {
headscaleDevices = data.machines.sort((a: Device, b: Device) => (a[sortKey as keyof Device] < b[sortKey as keyof Device] ? -1 : 1));
} else {