mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Push full TGO information in the event stream.
https://github.com/dcs-liberation/dcs_liberation/issues/2263
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { AppDispatch } from "../app/store";
|
||||
import { gameUnloaded } from "./actions";
|
||||
import backend from "./backend";
|
||||
import Combat from "./combat";
|
||||
import { endCombat, newCombat, updateCombat } from "./combatSlice";
|
||||
import { updateControlPoint } from "./controlPointsSlice";
|
||||
@@ -48,7 +47,7 @@ interface GameUpdateEvents {
|
||||
deselected_flight: boolean;
|
||||
updated_front_lines: FrontLine[];
|
||||
deleted_front_lines: string[];
|
||||
updated_tgos: string[];
|
||||
updated_tgos: Tgo[];
|
||||
updated_control_points: ControlPoint[];
|
||||
updated_iads: IadsConnection[];
|
||||
deleted_iads: string[];
|
||||
@@ -131,11 +130,8 @@ export const handleStreamedEvents = (
|
||||
dispatch(deleteFrontLine(events.deleted_front_lines));
|
||||
}
|
||||
|
||||
for (const id of events.updated_tgos) {
|
||||
backend.get(`/tgos/${id}`).then((response) => {
|
||||
const tgo = response.data as Tgo;
|
||||
dispatch(updateTgo(tgo));
|
||||
});
|
||||
if (events.updated_tgos.length > 0) {
|
||||
dispatch(updateTgo(events.updated_tgos));
|
||||
}
|
||||
|
||||
if (events.updated_control_points.length > 0) {
|
||||
|
||||
@@ -15,9 +15,10 @@ export const tgosSlice = createSlice({
|
||||
name: "tgos",
|
||||
initialState,
|
||||
reducers: {
|
||||
updateTgo: (state, action: PayloadAction<Tgo>) => {
|
||||
const tgo = action.payload;
|
||||
state.tgos[tgo.id] = tgo;
|
||||
updateTgo: (state, action: PayloadAction<Tgo[]>) => {
|
||||
for (const tgo of action.payload) {
|
||||
state.tgos[tgo.id] = tgo;
|
||||
}
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
|
||||
Reference in New Issue
Block a user