diff --git a/src/hooks/roofcover/useAuxiliaryDrawing.js b/src/hooks/roofcover/useAuxiliaryDrawing.js index 6e95e79c..1a0d87bd 100644 --- a/src/hooks/roofcover/useAuxiliaryDrawing.js +++ b/src/hooks/roofcover/useAuxiliaryDrawing.js @@ -455,9 +455,24 @@ export function useAuxiliaryDrawing(id) { name: 'auxiliaryLine', }) - lineHistory.current.push(line) + const historyLines = [...lineHistory.current] + + const hasSameLine = historyLines.some((history) => { + return ( + (isSamePoint(history.startPoint, line.startPoint) && isSamePoint(history.endPoint, line.endPoint)) || + (isSamePoint(history.startPoint, line.endPoint) && isSamePoint(history.endPoint, line.startPoint)) + ) + }) + mousePointerArr.current = [] clear() + + if (hasSameLine) { + canvas.remove(line) + return + } + + lineHistory.current.push(line) } const mouseDown = (e) => {