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:
parent
0fc2e8872d
commit
a20b95bb26
@ -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) => {
|
||||
|
||||
@ -11,6 +11,7 @@ from game.server.flights.models import FlightJs
|
||||
from game.server.frontlines.models import FrontLineJs
|
||||
from game.server.iadsnetwork.models import IadsConnectionJs
|
||||
from game.server.leaflet import LeafletPoint
|
||||
from game.server.tgos.models import TgoJs
|
||||
from game.server.mapzones.models import UnculledZoneJs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@ -33,7 +34,7 @@ class GameUpdateEventsJs(BaseModel):
|
||||
deselected_flight: bool
|
||||
updated_front_lines: list[FrontLineJs]
|
||||
deleted_front_lines: set[UUID]
|
||||
updated_tgos: set[UUID]
|
||||
updated_tgos: list[TgoJs]
|
||||
updated_control_points: list[ControlPointJs]
|
||||
updated_iads: list[IadsConnectionJs]
|
||||
deleted_iads: set[UUID]
|
||||
@ -88,7 +89,7 @@ class GameUpdateEventsJs(BaseModel):
|
||||
FrontLineJs.for_front_line(f) for f in events.updated_front_lines
|
||||
],
|
||||
deleted_front_lines=events.deleted_front_lines,
|
||||
updated_tgos=events.updated_tgos,
|
||||
updated_tgos=[TgoJs.for_tgo(tgo) for tgo in events.updated_tgos],
|
||||
updated_control_points=[
|
||||
ControlPointJs.for_control_point(cp)
|
||||
for cp in events.updated_control_points
|
||||
|
||||
@ -32,7 +32,7 @@ class GameUpdateEvents:
|
||||
deselected_flight: bool = False
|
||||
updated_front_lines: set[FrontLine] = field(default_factory=set)
|
||||
deleted_front_lines: set[UUID] = field(default_factory=set)
|
||||
updated_tgos: set[UUID] = field(default_factory=set)
|
||||
updated_tgos: set[TheaterGroundObject] = field(default_factory=set)
|
||||
updated_control_points: set[ControlPoint] = field(default_factory=set)
|
||||
updated_iads: set[IadsNetworkNode] = field(default_factory=set)
|
||||
deleted_iads_connections: set[UUID] = field(default_factory=set)
|
||||
@ -118,7 +118,7 @@ class GameUpdateEvents:
|
||||
return self
|
||||
|
||||
def update_tgo(self, tgo: TheaterGroundObject) -> GameUpdateEvents:
|
||||
self.updated_tgos.add(tgo.id)
|
||||
self.updated_tgos.add(tgo)
|
||||
return self
|
||||
|
||||
def update_control_point(self, control_point: ControlPoint) -> GameUpdateEvents:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user