2d undo redo bug fix
This commit is contained in:
@@ -32,7 +32,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
const { toolMode } = useToolMode();
|
||||
const { wallStore, floorStore, zoneStore, undoRedo2DStore } = useSceneContext();
|
||||
const { push2D } = undoRedo2DStore();
|
||||
const { removeWallByPoints, setPosition: setWallPosition, getWallsByPointId } = wallStore();
|
||||
const { removeWallByPoints, setPosition: setWallPosition, getWallByPoints, getConnectedWallsByWallId } = wallStore();
|
||||
const { removeFloorByPoints, setPosition: setFloorPosition, getFloorsByPointId, getFloorsByPoints } = floorStore();
|
||||
const { removeZoneByPoints, setPosition: setZonePosition, getZonesByPointId, getZonesByPoints } = zoneStore();
|
||||
const { userId, organization } = getUserData();
|
||||
@@ -361,27 +361,31 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
const offset = new THREE.Vector3().subVectors(midPoint, hit);
|
||||
setDragOffset(offset);
|
||||
|
||||
if (points[0].pointType === 'Wall') {
|
||||
const walls = getWallsByPointId(points[0].pointUuid);
|
||||
setInitialPositions({ walls });
|
||||
} else if (points[0].pointType === 'Floor') {
|
||||
if (points[0].pointType === 'Wall' && points[1].pointType === 'Wall') {
|
||||
const wall = getWallByPoints(points);
|
||||
if (wall) {
|
||||
const walls = getConnectedWallsByWallId(wall.wallUuid, false);
|
||||
setInitialPositions({ walls });
|
||||
}
|
||||
} else if (points[0].pointType === 'Floor' && points[0].pointType === 'Floor') {
|
||||
const floors = getFloorsByPointId(points[0].pointUuid);
|
||||
setInitialPositions({ floors });
|
||||
} else if (points[0].pointType === 'Zone') {
|
||||
} else if (points[0].pointType === 'Zone' && points[0].pointType === 'Zone') {
|
||||
const zones = getZonesByPointId(points[0].pointUuid);
|
||||
setInitialPositions({ zones });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleDragEnd = (points: [Point, Point]) => {
|
||||
const handleDragEnd = (points: [Point, Point]) => {
|
||||
if (toolMode !== 'move' || !dragOffset) return;
|
||||
handleCanvasCursors('default');
|
||||
setDragOffset(null);
|
||||
|
||||
if (points[0].pointType === 'Wall' && points[1].pointType === 'Wall') {
|
||||
const updatedWalls1 = getWallsByPointId(points[0].pointUuid);
|
||||
const updatedWalls2 = getWallsByPointId(points[1].pointUuid);
|
||||
const updatedWalls = [...updatedWalls1, ...updatedWalls2].filter((wall, index, self) => index === self.findIndex((w) => w.wallUuid === wall.wallUuid));
|
||||
const wall = getWallByPoints(points);
|
||||
if (!wall) return;
|
||||
const updatedWalls = getConnectedWallsByWallId(wall.wallUuid, false);
|
||||
|
||||
if (updatedWalls.length > 0 && projectId) {
|
||||
updatedWalls.forEach(updatedWall => {
|
||||
|
||||
Reference in New Issue
Block a user