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.`);
|
||||
}}
|
||||
onRoadRightClick={(id) => {
|
||||
// Right-click hides immediately. Hide is session-only and clears
|
||||
// when OSM edit mode exits or focused video changes.
|
||||
setHiddenRoadIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
next.add(id);
|
||||
return next;
|
||||
});
|
||||
setSelectedRoadIds((prev) => {
|
||||
if (!prev.has(id)) return prev;
|
||||
const next = new Set(prev);
|
||||
next.delete(id);
|
||||
return next;
|
||||
});
|
||||
pushOsmUndo({ kind: "unhide", ids: [id], label: "hide road" });
|
||||
setStatus(`Road #${id} hidden (session-only).`);
|
||||
// Right-click deletes the road from the DB. Snapshot first so the
|
||||
// OSM undo ring can resurrect it via restore_road_state's upsert
|
||||
// path (re-inserts the row with its original id + modified flag).
|
||||
// Hide-by-Del in focused-video mode is a separate, non-destructive
|
||||
// path.
|
||||
(async () => {
|
||||
try {
|
||||
await snapshotRoadsForUndo([id], "delete road (right-click)");
|
||||
await invoke("delete_osm_road", { id });
|
||||
setSelectedRoadIds((prev) => {
|
||||
if (!prev.has(id)) return prev;
|
||||
const next = new Set(prev);
|
||||
next.delete(id);
|
||||
return next;
|
||||
});
|
||||
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}
|
||||
roadOffsetMeters={roadOffsetMeters}
|
||||
|
||||
Reference in New Issue
Block a user