From ac5deafbbf517904a85b7f0e9b6f7e53f2a0ea3f Mon Sep 17 00:00:00 2001 From: ravi Date: Tue, 19 May 2026 14:44:20 +0530 Subject: [PATCH] road delete instead of hide --- src/App.tsx | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 681cbf6..94ea364 100644 --- a/src/App.tsx +++ b/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}