2d undo redo bug fix
This commit is contained in:
@@ -25,6 +25,7 @@ interface WallStore {
|
||||
getWallByPoints: (points: Point[]) => Wall | undefined;
|
||||
getWallPointById: (uuid: string) => Point | undefined;
|
||||
getConnectedPoints: (uuid: string) => Point[];
|
||||
getConnectedWallsByWallId: (wallUuid: string, skipSelf: boolean) => Wall[];
|
||||
}
|
||||
|
||||
export const createWallStore = () => {
|
||||
@@ -178,7 +179,7 @@ export const createWallStore = () => {
|
||||
|
||||
getWallsByPointId: (uuid) => {
|
||||
return get().walls.filter((a) => {
|
||||
return a.points.some((p) => p.pointUuid === uuid);
|
||||
return JSON.parse(JSON.stringify(a.points.some((p) => p.pointUuid === uuid)));
|
||||
})
|
||||
},
|
||||
|
||||
@@ -211,6 +212,19 @@ export const createWallStore = () => {
|
||||
}
|
||||
return connected;
|
||||
},
|
||||
|
||||
getConnectedWallsByWallId: (wallUuid, skipSelf) => {
|
||||
const wall = get().walls.find(w => w.wallUuid === wallUuid);
|
||||
if (!wall) return [];
|
||||
|
||||
const pointUuids = wall.points.map(p => p.pointUuid);
|
||||
|
||||
return get().walls.filter(w => {
|
||||
if (skipSelf && w.wallUuid === wallUuid) return false;
|
||||
return w.points.some(p => pointUuids.includes(p.pointUuid));
|
||||
});
|
||||
},
|
||||
|
||||
}))
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user