road delete instead of hide
This commit is contained in:
38
src/App.tsx
38
src/App.tsx
@@ -3305,21 +3305,29 @@ function AppShell({
|
|||||||
setStatus(`Editing road #${id}. Drag the gold vertex dots.`);
|
setStatus(`Editing road #${id}. Drag the gold vertex dots.`);
|
||||||
}}
|
}}
|
||||||
onRoadRightClick={(id) => {
|
onRoadRightClick={(id) => {
|
||||||
// Right-click hides immediately. Hide is session-only and clears
|
// Right-click deletes the road from the DB. Snapshot first so the
|
||||||
// when OSM edit mode exits or focused video changes.
|
// OSM undo ring can resurrect it via restore_road_state's upsert
|
||||||
setHiddenRoadIds((prev) => {
|
// path (re-inserts the row with its original id + modified flag).
|
||||||
const next = new Set(prev);
|
// Hide-by-Del in focused-video mode is a separate, non-destructive
|
||||||
next.add(id);
|
// path.
|
||||||
return next;
|
(async () => {
|
||||||
});
|
try {
|
||||||
setSelectedRoadIds((prev) => {
|
await snapshotRoadsForUndo([id], "delete road (right-click)");
|
||||||
if (!prev.has(id)) return prev;
|
await invoke("delete_osm_road", { id });
|
||||||
const next = new Set(prev);
|
setSelectedRoadIds((prev) => {
|
||||||
next.delete(id);
|
if (!prev.has(id)) return prev;
|
||||||
return next;
|
const next = new Set(prev);
|
||||||
});
|
next.delete(id);
|
||||||
pushOsmUndo({ kind: "unhide", ids: [id], label: "hide road" });
|
return next;
|
||||||
setStatus(`Road #${id} hidden (session-only).`);
|
});
|
||||||
|
if (editingRoadId === id) setEditingRoadId(null);
|
||||||
|
setMarkedVertices(new Set());
|
||||||
|
await refreshOsmRoads();
|
||||||
|
setStatus(`Road #${id} deleted. Use Undo to bring it back.`);
|
||||||
|
} catch (e) {
|
||||||
|
setStatus(`Delete failed: ${e}`);
|
||||||
|
}
|
||||||
|
})();
|
||||||
}}
|
}}
|
||||||
onUpdateRoad={handleUpdateRoad}
|
onUpdateRoad={handleUpdateRoad}
|
||||||
roadOffsetMeters={roadOffsetMeters}
|
roadOffsetMeters={roadOffsetMeters}
|
||||||
|
|||||||
Reference in New Issue
Block a user