mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-05 18:02:55 +00:00
real incremental immer patches
This commit is contained in:
@@ -6,7 +6,6 @@ import { currentPopupWaypoint, deleteWaypoint, waypointPopup } from "./WaypointP
|
||||
import { addSelectItem, selectItem, selection } from "$lib/components/file-list/Selection";
|
||||
import { ListTrackSegmentItem, ListWaypointItem, ListWaypointsItem, ListTrackItem, ListFileItem, ListRootItem } from "$lib/components/file-list/FileList";
|
||||
import type { Waypoint } from "gpx";
|
||||
import { produce } from "immer";
|
||||
import { resetCursor, setCursor, setGrabbingCursor, setPointerCursor } from "$lib/utils";
|
||||
import { font } from "$lib/assets/layers";
|
||||
import { selectedWaypoint } from "$lib/components/toolbar/tools/Waypoint.svelte";
|
||||
@@ -231,13 +230,13 @@ export class GPXLayer {
|
||||
resetCursor();
|
||||
marker.getElement().style.cursor = '';
|
||||
dbUtils.applyToFile(this.fileId, (file) => {
|
||||
return produce(file, (draft) => {
|
||||
let latLng = marker.getLngLat();
|
||||
draft.wpt[marker._waypoint._data.index].setCoordinates({
|
||||
lat: latLng.lat,
|
||||
lon: latLng.lng
|
||||
});
|
||||
let latLng = marker.getLngLat();
|
||||
let wpt = file.wpt[marker._waypoint._data.index];
|
||||
wpt.setCoordinates({
|
||||
lat: latLng.lat,
|
||||
lon: latLng.lng
|
||||
});
|
||||
wpt.ele = this.map.queryTerrainElevation([latLng.lng, latLng.lat], { exaggerated: false }) ?? 0;
|
||||
});
|
||||
dragEndTimestamp = Date.now()
|
||||
});
|
||||
|
@@ -21,5 +21,5 @@ export const waypointPopup = new mapboxgl.Popup({
|
||||
});
|
||||
|
||||
export function deleteWaypoint(fileId: string, waypointIndex: number) {
|
||||
dbUtils.applyToFile(fileId, (file) => file.replaceWaypoints(waypointIndex, waypointIndex, [])[0]);
|
||||
dbUtils.applyToFile(fileId, (file) => file.replaceWaypoints(waypointIndex, waypointIndex, []));
|
||||
}
|
Reference in New Issue
Block a user