Skip to content

Commit

Permalink
Merge pull request #40 from gurucomputing/34-last-seen-sort-works-in-…
Browse files Browse the repository at this point in the history
…wrong-direction

fix sort based on lastseen
  • Loading branch information
routerino authored Aug 13, 2022
2 parents e50bcb7 + c81e61d commit 60bd0be
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/common/apiFunctions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 60bd0be

Please sign in to comment.