mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add websocket handling for selected flights.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { Flight } from "../../api/flight";
|
||||
import FlightPlan from "../flightplan";
|
||||
import { LayerGroup } from "react-leaflet";
|
||||
import { selectFlights } from "../../api/flightsSlice";
|
||||
@@ -10,11 +11,29 @@ interface FlightPlansLayerProps {
|
||||
export default function FlightPlansLayer(props: FlightPlansLayerProps) {
|
||||
const atos = useAppSelector(selectFlights);
|
||||
const flights = props.blue ? atos.blue : atos.red;
|
||||
const isNotSelected = (flight: Flight) => {
|
||||
if (atos.selected == null) {
|
||||
return true;
|
||||
}
|
||||
return atos.selected.id !== flight.id;
|
||||
};
|
||||
|
||||
const selectedFlight = atos.selected ? (
|
||||
<FlightPlan key={atos.selected.id} flight={atos.selected} selected={true} />
|
||||
) : (
|
||||
<></>
|
||||
);
|
||||
|
||||
return (
|
||||
<LayerGroup>
|
||||
{Object.values(flights).map((flight) => {
|
||||
return <FlightPlan key={flight.id} flight={flight} selected={false} />;
|
||||
})}
|
||||
{Object.values(flights)
|
||||
.filter(isNotSelected)
|
||||
.map((flight) => {
|
||||
return (
|
||||
<FlightPlan key={flight.id} flight={flight} selected={false} />
|
||||
);
|
||||
})}
|
||||
{selectedFlight}
|
||||
</LayerGroup>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user