From 5e37c7f4b85a0f42df745415feac591a9aa4fc9b Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 28 Nov 2021 17:52:28 +0000 Subject: [PATCH] Sort device location history entries by timestamp Fixes #67. --- src/api.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api.js b/src/api.js index ade6c85..c7ee20c 100644 --- a/src/api.js +++ b/src/api.js @@ -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", () =>