Fix flight plan updates when waypoints are moved.

The store serializes everything; we can't store references.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2055
This commit is contained in:
Dan Albert
2022-03-06 22:18:36 -08:00
parent 0afe1f69d4
commit b08b91ca2e
2 changed files with 23 additions and 17 deletions

View File

@@ -6,7 +6,7 @@ import { LatLng } from "leaflet";
interface FlightsState {
flights: { [id: string]: Flight };
selected: Flight | null;
selected: string | null;
}
const initialState: FlightsState = {
@@ -37,8 +37,7 @@ export const flightsSlice = createSlice({
state.selected = null;
},
selectFlight: (state, action: PayloadAction<string>) => {
const id = action.payload;
state.selected = state.flights[id];
state.selected = action.payload;
},
updateFlightPositions: (
state,
@@ -77,5 +76,9 @@ export const {
} = flightsSlice.actions;
export const selectFlights = (state: RootState) => state.flights;
export const selectSelectedFlight = (state: RootState) => {
const id = state.flights.selected;
return id ? state.flights.flights[id] : null;
};
export default flightsSlice.reducer;