route api: try and bundle requests

this limits the responsiveness to 3 seconds but that's fine
it's still fast if there is lots of routes to look up on page load for
example
This commit is contained in:
Matthias Wirth
2025-10-23 14:19:07 +00:00
parent 22e8d008cb
commit 589e1edefe
2 changed files with 12 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ g.route_cache = [];
g.route_check_todo = {};
g.route_check_in_flight = false;
g.route_next_lookup = 0;
g.route_last_lookup = 0;
g.mapOrientation = mapOrientation;
@@ -5739,7 +5740,7 @@ function checkMovement() {
return;
}
let currentTime = new Date().getTime()/1000;
let currentTime = Date.now()/1000;
if (currentTime > g.route_next_lookup && !g.route_check_in_flight) {
// check if it's time to send a batch of request to the API server
g.route_next_lookup = currentTime + 1;