From 4dfc42528dd7e32c5adde6604b708cd6ef41c776 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 3 Mar 2022 00:10:45 -0800 Subject: [PATCH] Eliminate unnecessary waypoint API call in map. I added the with_waypoints option for the react map. Use it in the old one. --- resources/ui/map/map.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/resources/ui/map/map.js b/resources/ui/map/map.js index 34eff9c1..90355889 100644 --- a/resources/ui/map/map.js +++ b/resources/ui/map/map.js @@ -924,24 +924,22 @@ class Flight { } drawFlightPlan() { - getJson(`/waypoints/${this.flight.id}`).then((waypoints) => { - this.clearFlightPlan(); - const path = []; - waypoints.map((raw, idx) => { - const waypoint = new Waypoint(raw, idx, this); - if (waypoint.includeInPath()) { - path.push(waypoint.position()); - } - if (this.shouldMark(waypoint)) { - waypoint.marker - .addTo(selectedFlightPlansLayer) - .addTo(this.flightPlanLayer()) - .addTo(allFlightPlansLayer); - this.markers.push(waypoint.marker); - } - }); - this.drawPath(path); + this.clearFlightPlan(); + const path = []; + this.flight.waypoints.map((raw, idx) => { + const waypoint = new Waypoint(raw, idx, this); + if (waypoint.includeInPath()) { + path.push(waypoint.position()); + } + if (this.shouldMark(waypoint)) { + waypoint.marker + .addTo(selectedFlightPlansLayer) + .addTo(this.flightPlanLayer()) + .addTo(allFlightPlansLayer); + this.markers.push(waypoint.marker); + } }); + this.drawPath(path); } } @@ -953,7 +951,7 @@ function drawAircraft() { selectedFlightPlansLayer.clearLayers(); allFlightPlansLayer.clearLayers(); - getJson("/flights").then((flights) => { + getJson("/flights?with_waypoints=true").then((flights) => { for (const flight of flights) { new Flight(flight).draw(); }