Skip to content

Commit 5e37c7f

Browse files
committed
Sort device location history entries by timestamp
Fixes #67.
1 parent 7dda60d commit 5e37c7f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ export const getUserDeviceLocationHistory = async (
136136
fetchOptions
137137
);
138138
const json = await response.json();
139-
const userDeviceLocationHistory = json.data;
139+
// We need to manually sort by timestamp, otherwise the line segments may be
140+
// drawn in the wrong order. The recorder API simply returns entries in the
141+
// same order in which they are in each *.rec file.
142+
// See https://github.com/owntracks/frontend/issues/67.
143+
const userDeviceLocationHistory = json.data.sort((a, b) => a.tst - b.tst);
140144
log(
141145
"API",
142146
() =>

0 commit comments

Comments
 (0)