mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Push full front line information in the event stream.
https://github.com/dcs-liberation/dcs_liberation/issues/2263
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
updateFlightPositions,
|
||||
} from "./flightsSlice";
|
||||
import {
|
||||
addFrontLine,
|
||||
deleteFrontLine,
|
||||
updateFrontLine,
|
||||
} from "./frontLinesSlice";
|
||||
@@ -47,8 +46,7 @@ interface GameUpdateEvents {
|
||||
deleted_flights: string[];
|
||||
selected_flight: string | null;
|
||||
deselected_flight: boolean;
|
||||
new_front_lines: FrontLine[];
|
||||
updated_front_lines: string[];
|
||||
updated_front_lines: FrontLine[];
|
||||
deleted_front_lines: string[];
|
||||
updated_tgos: string[];
|
||||
updated_control_points: number[];
|
||||
@@ -123,19 +121,12 @@ export const handleStreamedEvents = (
|
||||
dispatch(selectFlight(events.selected_flight));
|
||||
}
|
||||
|
||||
for (const front of events.new_front_lines) {
|
||||
dispatch(addFrontLine(front));
|
||||
if (events.updated_front_lines.length > 0) {
|
||||
dispatch(updateFrontLine(events.updated_front_lines));
|
||||
}
|
||||
|
||||
for (const id of events.updated_front_lines) {
|
||||
backend.get(`/front-lines/${id}`).then((response) => {
|
||||
const front = response.data as FrontLine;
|
||||
dispatch(updateFrontLine(front));
|
||||
});
|
||||
}
|
||||
|
||||
for (const id of events.deleted_front_lines) {
|
||||
dispatch(deleteFrontLine(id));
|
||||
if (events.deleted_front_lines.length > 0) {
|
||||
dispatch(deleteFrontLine(events.deleted_front_lines));
|
||||
}
|
||||
|
||||
for (const id of events.updated_tgos) {
|
||||
|
||||
@@ -15,16 +15,15 @@ export const frontLinesSlice = createSlice({
|
||||
name: "frontLines",
|
||||
initialState,
|
||||
reducers: {
|
||||
addFrontLine: (state, action: PayloadAction<FrontLine>) => {
|
||||
const front = action.payload;
|
||||
state.fronts[front.id] = front;
|
||||
updateFrontLine: (state, action: PayloadAction<FrontLine[]>) => {
|
||||
for (const front of action.payload) {
|
||||
state.fronts[front.id] = front;
|
||||
}
|
||||
},
|
||||
updateFrontLine: (state, action: PayloadAction<FrontLine>) => {
|
||||
const front = action.payload;
|
||||
state.fronts[front.id] = front;
|
||||
},
|
||||
deleteFrontLine: (state, action: PayloadAction<string>) => {
|
||||
delete state.fronts[action.payload];
|
||||
deleteFrontLine: (state, action: PayloadAction<string[]>) => {
|
||||
for (const uid of action.payload) {
|
||||
delete state.fronts[uid];
|
||||
}
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
@@ -43,7 +42,7 @@ export const frontLinesSlice = createSlice({
|
||||
},
|
||||
});
|
||||
|
||||
export const { addFrontLine, updateFrontLine, deleteFrontLine } =
|
||||
export const { updateFrontLine, deleteFrontLine } =
|
||||
frontLinesSlice.actions;
|
||||
|
||||
export const selectFrontLines = (state: RootState) => state.frontLines;
|
||||
|
||||
Reference in New Issue
Block a user