Push full control point information in the event stream.

https://github.com/dcs-liberation/dcs_liberation/issues/2263
This commit is contained in:
Raffson
2022-06-25 23:17:08 +02:00
committed by GitHub
parent da90a40bc4
commit 61488627a4
5 changed files with 23 additions and 17 deletions

View File

@@ -15,9 +15,10 @@ export const controlPointsSlice = createSlice({
name: "controlPoints",
initialState,
reducers: {
updateControlPoint: (state, action: PayloadAction<ControlPoint>) => {
const cp = action.payload;
state.controlPoints[cp.id] = cp;
updateControlPoint: (state, action: PayloadAction<ControlPoint[]>) => {
for (const cp of action.payload) {
state.controlPoints[cp.id] = cp;
}
},
},
extraReducers: (builder) => {

View File

@@ -49,7 +49,7 @@ interface GameUpdateEvents {
updated_front_lines: FrontLine[];
deleted_front_lines: string[];
updated_tgos: string[];
updated_control_points: number[];
updated_control_points: ControlPoint[];
reset_on_map_center: LatLng | null;
game_unloaded: boolean;
new_turn: boolean;
@@ -141,11 +141,8 @@ export const handleStreamedEvents = (
});
}
for (const id of events.updated_control_points) {
backend.get(`/control-points/${id}`).then((response) => {
const cp = response.data as ControlPoint;
dispatch(updateControlPoint(cp));
});
if (events.updated_control_points.length > 0) {
dispatch(updateControlPoint(events.updated_control_points));
}
if (events.reset_on_map_center != null) {