mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Respond to ATO changes in the new UI.
This commit is contained in:
parent
cba39df5da
commit
6933470ce0
@ -3,7 +3,13 @@ import backend from "./backend";
|
|||||||
import { updateControlPoint } from "./controlPointsSlice";
|
import { updateControlPoint } from "./controlPointsSlice";
|
||||||
import { ControlPoint } from "./controlpoint";
|
import { ControlPoint } from "./controlpoint";
|
||||||
import { Flight } from "./flight";
|
import { Flight } from "./flight";
|
||||||
import { deselectFlight, selectFlight } from "./flightsSlice";
|
import {
|
||||||
|
deselectFlight,
|
||||||
|
registerFlight,
|
||||||
|
selectFlight,
|
||||||
|
unregisterFlight,
|
||||||
|
updateFlight,
|
||||||
|
} from "./flightsSlice";
|
||||||
import {
|
import {
|
||||||
addFrontLine,
|
addFrontLine,
|
||||||
deleteFrontLine,
|
deleteFrontLine,
|
||||||
@ -42,6 +48,21 @@ export const handleStreamedEvents = (
|
|||||||
dispatch: AppDispatch,
|
dispatch: AppDispatch,
|
||||||
events: GameUpdateEvents
|
events: GameUpdateEvents
|
||||||
) => {
|
) => {
|
||||||
|
for (const flight of events.new_flights) {
|
||||||
|
dispatch(registerFlight(flight));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const id of events.updated_flights) {
|
||||||
|
backend.get(`/flights/${id}?with_waypoints=true`).then((response) => {
|
||||||
|
const flight = response.data as Flight;
|
||||||
|
dispatch(updateFlight(flight));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const id of events.deleted_flights) {
|
||||||
|
dispatch(unregisterFlight(id));
|
||||||
|
}
|
||||||
|
|
||||||
if (events.deselected_flight) {
|
if (events.deselected_flight) {
|
||||||
dispatch(deselectFlight());
|
dispatch(deselectFlight());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,11 @@ export const flightsSlice = createSlice({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
updateFlight: (state, action: PayloadAction<Flight>) => {
|
||||||
|
const flight = action.payload;
|
||||||
|
const ato = flight.blue ? state.blue : state.red;
|
||||||
|
ato[flight.id] = flight;
|
||||||
|
},
|
||||||
deselectFlight: (state) => {
|
deselectFlight: (state) => {
|
||||||
state.selected = null;
|
state.selected = null;
|
||||||
},
|
},
|
||||||
@ -57,6 +62,7 @@ export const {
|
|||||||
clearFlights,
|
clearFlights,
|
||||||
registerFlight,
|
registerFlight,
|
||||||
unregisterFlight,
|
unregisterFlight,
|
||||||
|
updateFlight,
|
||||||
deselectFlight,
|
deselectFlight,
|
||||||
selectFlight,
|
selectFlight,
|
||||||
} = flightsSlice.actions;
|
} = flightsSlice.actions;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user