Prevent drawing flights that are being deleted.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1720
This commit is contained in:
Dan Albert
2021-11-21 13:21:25 -08:00
parent 8c2e25339f
commit bc819d59f4
2 changed files with 37 additions and 20 deletions

View File

@@ -892,20 +892,34 @@ class Flight {
}
drawFlightPlan() {
const path = [];
this.flightPlan.forEach((waypoint) => {
if (waypoint.includeInPath()) {
path.push(waypoint.position());
this.flight.flightIsInAto().then((inAto) => {
if (!inAto) {
// HACK: The signal to redraw the ATO following package/flight deletion
// and the signal to change flight/package selection due to UI selection
// change come in an arbitrary order. If redraw signal comes first the UI
// will clear the map and redraw, but then when the UI updates selection
// away from the (now deleted) flight/package it calls deselect, which
// redraws the deleted flight plan in its deselected state.
//
// Avoid this by checking that the flight is still in the coalition's ATO
// before drawing.
return;
}
if (this.shouldMark(waypoint)) {
waypoint.marker
.addTo(selectedFlightPlansLayer)
.addTo(this.flightPlanLayer())
.addTo(allFlightPlansLayer);
}
});
const path = [];
this.flightPlan.forEach((waypoint) => {
if (waypoint.includeInPath()) {
path.push(waypoint.position());
}
if (this.shouldMark(waypoint)) {
waypoint.marker
.addTo(selectedFlightPlansLayer)
.addTo(this.flightPlanLayer())
.addTo(allFlightPlansLayer);
}
});
this.drawPath(path);
this.drawPath(path);
});
}
}