mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
There are still two more of these that don't show up in openapi.json because they don't show up in HTTP routes (only in the websocket): * GameUpdateEvents * FrozenCombat I'm not sure if there's a way to forcibly include those in the openapi.json, if I should add a no-op API to force it to happen, or if I should just ignore it. For now I'm going with option 3.
25 lines
676 B
TypeScript
25 lines
676 B
TypeScript
import { AppDispatch } from "../app/store";
|
|
import { gameLoaded, gameUnloaded } from "./actions";
|
|
import backend from "./backend";
|
|
import { Game } from "./liberationApi";
|
|
|
|
export default function reloadGameState(
|
|
dispatch: AppDispatch,
|
|
ignoreRecenter: boolean = false
|
|
) {
|
|
backend
|
|
.get("/game")
|
|
.catch((error) => console.log(`Error fetching game state: ${error}`))
|
|
.then((response) => {
|
|
if (response == null || response.data == null) {
|
|
dispatch(gameUnloaded());
|
|
return;
|
|
}
|
|
const game = response.data as Game;
|
|
if (ignoreRecenter) {
|
|
game.map_center = undefined;
|
|
}
|
|
dispatch(gameLoaded(game));
|
|
});
|
|
}
|