refactor: Update connection identifiers from pathUUID to modelUUID across simulation components

This commit is contained in:
2025-04-05 15:15:01 +05:30
parent 1cc877aee1
commit b89589d8ea
10 changed files with 162 additions and 86 deletions

View File

@@ -29,7 +29,7 @@
// position: [number, number, number];
// actions: PointAction[];
// connections: {
// targets: Array<{ pathUUID: string }>;
// targets: Array<{ modelUUID: string }>;
// };
// }
@@ -72,7 +72,7 @@
// actions: point.actions.map(normalizeAction), // Preserve exact actions
// connections: {
// targets: point.connections.targets.map((target) => ({
// pathUUID: target.pathUUID,
// modelUUID: target.modelUUID,
// })),
// },
// })),
@@ -94,7 +94,7 @@
// : [normalizeAction(path.point.actions)],
// connections: {
// targets: path.point.connections.targets.map((target) => ({
// pathUUID: target.pathUUID,
// modelUUID: target.modelUUID,
// })),
// },
// },
@@ -137,18 +137,18 @@
// // Check if current last connects to next last (requires reversal)
// const connectsToLast = currentLastPoint.connections.targets.some(
// (target) =>
// target.pathUUID === nextPath.modeluuid &&
// target.modelUUID === nextPath.modeluuid &&
// nextLastPoint.connections.targets.some(
// (t) => t.pathUUID === currentPath.modeluuid
// (t) => t.modelUUID === currentPath.modeluuid
// )
// );
// // Check if current last connects to next first (no reversal needed)
// const connectsToFirst = currentLastPoint.connections.targets.some(
// (target) =>
// target.pathUUID === nextPath.modeluuid &&
// target.modelUUID === nextPath.modeluuid &&
// nextFirstPoint.connections.targets.some(
// (t) => t.pathUUID === currentPath.modeluuid
// (t) => t.modelUUID === currentPath.modeluuid
// )
// );
@@ -249,10 +249,10 @@
// // Process outgoing connections
// for (const point of currentPath.points) {
// for (const target of point.connections.targets) {
// if (!visited.has(target.pathUUID)) {
// const targetPath = pathMap.get(target.pathUUID);
// if (!visited.has(target.modelUUID)) {
// const targetPath = pathMap.get(target.modelUUID);
// if (targetPath) {
// visited.add(target.pathUUID);
// visited.add(target.modelUUID);
// queue.push(targetPath);
// }
// }
@@ -264,7 +264,7 @@
// if (!visited.has(uuid)) {
// const hasConnectionToCurrent = path.points.some((point) =>
// point.connections.targets.some(
// (t) => t.pathUUID === currentPath.modeluuid
// (t) => t.modelUUID === currentPath.modeluuid
// )
// );
// if (hasConnectionToCurrent) {
@@ -335,7 +335,7 @@
// ),
// connections: path.points
// .flatMap((p: PathPoint) =>
// p.connections.targets.map((t: { pathUUID: string }) => t.pathUUID)
// p.connections.targets.map((t: { modelUUID: string }) => t.modelUUID)
// )
// .join(","),
// }));
@@ -428,7 +428,7 @@ export interface PathPoint {
position: [number, number, number];
actions: PointAction[];
connections: {
targets: Array<{ pathUUID: string }>;
targets: Array<{ modelUUID: string }>;
};
}
@@ -473,7 +473,7 @@ function convertToSimulationPath(
actions: point.actions.map(normalizeAction), // Preserve exact actions
connections: {
targets: point.connections.targets.map((target) => ({
pathUUID: target.pathUUID,
modelUUID: target.modelUUID,
})),
},
})),
@@ -496,7 +496,7 @@ function convertToSimulationPath(
: [normalizeAction(path.points.actions)],
connections: {
targets: path.points.connections.targets.map((target) => ({
pathUUID: target.pathUUID,
modelUUID: target.modelUUID,
})),
},
},
@@ -539,18 +539,18 @@ function shouldReverseNextPath(
// Check if current last connects to next last (requires reversal)
const connectsToLast = currentLastPoint.connections.targets.some(
(target) =>
target.pathUUID === nextPath.modeluuid &&
target.modelUUID === nextPath.modeluuid &&
nextLastPoint.connections.targets.some(
(t) => t.pathUUID === currentPath.modeluuid
(t) => t.modelUUID === currentPath.modeluuid
)
);
// Check if current last connects to next first (no reversal needed)
const connectsToFirst = currentLastPoint.connections.targets.some(
(target) =>
target.pathUUID === nextPath.modeluuid &&
target.modelUUID === nextPath.modeluuid &&
nextFirstPoint.connections.targets.some(
(t) => t.pathUUID === currentPath.modeluuid
(t) => t.modelUUID === currentPath.modeluuid
)
);
@@ -678,10 +678,10 @@ export function useProcessCreation() {
// Process outgoing connections
for (const point of currentPath.points) {
for (const target of point.connections.targets) {
if (!visited.has(target.pathUUID)) {
const targetPath = pathMap.get(target.pathUUID);
if (!visited.has(target.modelUUID)) {
const targetPath = pathMap.get(target.modelUUID);
if (targetPath) {
visited.add(target.pathUUID);
visited.add(target.modelUUID);
queue.push(targetPath);
}
}
@@ -693,7 +693,7 @@ export function useProcessCreation() {
if (!visited.has(uuid)) {
const hasConnectionToCurrent = path.points.some((point) =>
point.connections.targets.some(
(t) => t.pathUUID === currentPath.modeluuid
(t) => t.modelUUID === currentPath.modeluuid
)
);
if (hasConnectionToCurrent) {
@@ -768,7 +768,7 @@ const ProcessCreator: React.FC<ProcessCreatorProps> = React.memo(
.join(","),
connections: path.points
.flatMap((p: PathPoint) =>
p.connections.targets.map((t: { pathUUID: string }) => t.pathUUID)
p.connections.targets.map((t: { modelUUID: string }) => t.modelUUID)
)
.join(","),
}));