mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Handle map reset when the game is loaded/unloaded.
https://github.com/dcs-liberation/dcs_liberation/issues/2039 Partial fix for https://github.com/dcs-liberation/dcs_liberation/issues/2045 (now works in the new map, old one not fixed yet).
This commit is contained in:
@@ -1,14 +1,4 @@
|
||||
import backend from "../api/backend";
|
||||
import { setControlPoints } from "../api/controlPointsSlice";
|
||||
import { ControlPoint } from "../api/controlpoint";
|
||||
import { Flight } from "../api/flight";
|
||||
import { registerFlight } from "../api/flightsSlice";
|
||||
import { setFrontLines } from "../api/frontLinesSlice";
|
||||
import FrontLine from "../api/frontline";
|
||||
import { setSupplyRoutes } from "../api/supplyRoutesSlice";
|
||||
import SupplyRoute from "../api/supplyroute";
|
||||
import Tgo from "../api/tgo";
|
||||
import { setTgos } from "../api/tgosSlice";
|
||||
import reloadGameState from "../api/gamestate";
|
||||
import { useAppDispatch } from "../app/hooks";
|
||||
import { useEffect } from "react";
|
||||
|
||||
@@ -19,48 +9,7 @@ import { useEffect } from "react";
|
||||
export const useInitialGameState = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
useEffect(() => {
|
||||
backend
|
||||
.get("/control-points")
|
||||
.catch((error) => console.log(`Error fetching control points: ${error}`))
|
||||
.then((response) => {
|
||||
if (response != null) {
|
||||
dispatch(setControlPoints(response.data as ControlPoint[]));
|
||||
}
|
||||
});
|
||||
backend
|
||||
.get("/tgos")
|
||||
.catch((error) => console.log(`Error fetching TGOs: ${error}`))
|
||||
.then((response) => {
|
||||
if (response != null) {
|
||||
dispatch(setTgos(response.data as Tgo[]));
|
||||
}
|
||||
});
|
||||
backend
|
||||
.get("/supply-routes")
|
||||
.catch((error) => console.log(`Error fetching supply routes: ${error}`))
|
||||
.then((response) => {
|
||||
if (response != null) {
|
||||
dispatch(setSupplyRoutes(response.data as SupplyRoute[]));
|
||||
}
|
||||
});
|
||||
backend
|
||||
.get("/front-lines")
|
||||
.catch((error) => console.log(`Error fetching front-lines: ${error}`))
|
||||
.then((response) => {
|
||||
if (response != null) {
|
||||
dispatch(setFrontLines(response.data as FrontLine[]));
|
||||
}
|
||||
});
|
||||
backend
|
||||
.get("/flights?with_waypoints=true")
|
||||
.catch((error) => console.log(`Error fetching flights: ${error}`))
|
||||
.then((response) => {
|
||||
if (response != null) {
|
||||
for (const flight of response.data) {
|
||||
dispatch(registerFlight(flight as Flight));
|
||||
}
|
||||
}
|
||||
});
|
||||
reloadGameState(dispatch);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user