Sort device location history entries by timestamp

Fixes #67.
This commit is contained in:
Linus Groh
2021-11-28 17:52:28 +00:00
parent 7dda60d457
commit 5e37c7f4b8
+5 -1
View File
@@ -136,7 +136,11 @@ export const getUserDeviceLocationHistory = async (
fetchOptions
);
const json = await response.json();
const userDeviceLocationHistory = json.data;
// We need to manually sort by timestamp, otherwise the line segments may be
// drawn in the wrong order. The recorder API simply returns entries in the
// same order in which they are in each *.rec file.
// See https://github.com/owntracks/frontend/issues/67.
const userDeviceLocationHistory = json.data.sort((a, b) => a.tst - b.tst);
log(
"API",
() =>