2d undo redo bug fix

This commit is contained in:
2025-08-23 15:27:17 +05:30
parent 51a5805756
commit e3bd30743d
8 changed files with 153 additions and 24 deletions

View File

@@ -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));
});
},
}))
)
}