mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix caching behavior of flight plan data.
This is far from complete but it at least covers anything related to flight plans. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2060
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import backend from "../../api/backend";
|
||||
import { Flight } from "../../api/liberationApi";
|
||||
import { Waypoint } from "../../api/liberationApi";
|
||||
import {
|
||||
Flight,
|
||||
Waypoint,
|
||||
useSetWaypointPositionMutation,
|
||||
} from "../../api/liberationApi";
|
||||
import { Icon } from "leaflet";
|
||||
import { Marker as LMarker } from "leaflet";
|
||||
import icon from "leaflet/dist/images/marker-icon.png";
|
||||
@@ -36,6 +38,8 @@ const WaypointMarker = (props: WaypointMarkerProps) => {
|
||||
const map = useMap();
|
||||
const marker: MutableRefObject<LMarker | undefined> = useRef();
|
||||
|
||||
const [putDestination] = useSetWaypointPositionMutation();
|
||||
|
||||
const rebindTooltip = useCallback(() => {
|
||||
if (marker.current === undefined) {
|
||||
return;
|
||||
@@ -73,13 +77,18 @@ const WaypointMarker = (props: WaypointMarkerProps) => {
|
||||
const m: LMarker = e.target;
|
||||
m.setTooltipContent("Waiting to recompute TOT...");
|
||||
},
|
||||
dragend: (e) => {
|
||||
dragend: async (e) => {
|
||||
const m: LMarker = e.target;
|
||||
const destination = m.getLatLng();
|
||||
backend.post(
|
||||
`/waypoints/${props.flight.id}/${props.number}/position`,
|
||||
destination
|
||||
);
|
||||
try {
|
||||
await putDestination({
|
||||
flightId: props.flight.id,
|
||||
waypointIdx: props.number,
|
||||
leafletPoint: { lat: destination.lat, lng: destination.lng },
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Failed to set waypoint position", e);
|
||||
}
|
||||
},
|
||||
}}
|
||||
ref={(ref) => {
|
||||
|
||||
Reference in New Issue
Block a user