Skip to content

Commit

Permalink
fix drawing connections
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaLysiuk committed Feb 12, 2024
1 parent 6af6933 commit be745d6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
50 changes: 28 additions & 22 deletions packages/editor-worker/src/tsAlgo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,50 +106,56 @@ export const sortNodesTs = ({
});
const connections: NumberConnection[] = [];
const idempotentInsert = (n: ParserField, tname: string) => {
const relatedNode = nodes.find((n) => n.name === tname);
const extensionNodes = !Object.keys(TypeExtension).includes(n.data.type)
? nodes.filter(
(extNode) =>
Object.keys(TypeExtension).includes(extNode.data.type) &&
n.name === extNode.name
)
: [];
for (const extNode of extensionNodes) {
if (extNode.id === n.id) return;
const relatedNode = nodes.find(
(n) =>
n.name === tname && !Object.keys(TypeExtension).includes(n.data.type)
);
if (relatedNode) {
if (relatedNode.id === n.id) return;
if (
connections.find((c) => c.source === n.id && c.target === extNode.id)
connections.find(
(c) => c.source === n.id && c.target === relatedNode.id
)
) {
return;
}
if (
connections.find((c) => c.source === extNode.id && c.target === n.id)
connections.find(
(c) => c.source === relatedNode.id && c.target === n.id
)
) {
return;
}
if (n.name === "neworpan" || n.name === "Coords") {
console.log("source", n.id, "target", relatedNode.id);
}
connections.push({
source: n.id,
target: extNode.id,
target: relatedNode.id,
});
}
if (relatedNode) {
if (relatedNode.id === n.id) return;
if (
connections.find(
(c) => c.source === n.id && c.target === relatedNode.id
const extensionNodes = !Object.keys(TypeExtension).includes(n.data.type)
? nodes.filter(
(extNode) =>
Object.keys(TypeExtension).includes(extNode.data.type) &&
n.name === extNode.name

This comment has been minimized.

Copy link
@aexol

aexol Feb 12, 2024

Contributor

Je艣li node nie jest extensionem to odfiltruje wszystkie extension nody kt贸rych nazwa jest nazw膮 noda? Czyli jak mam field people typu Person to b臋dzie szuka膰 extension noda typu people. I jak znajdzie to go pod艂膮czy i zn贸w b臋dzie b艂膮d

to musi tak:

  1. sprawdzamy czy node jest ekstendowalny najpierw
  2. odfiltrowac sobie extension nody gdzies wyzej i potem te sprawdzenie po name ma sens
)
: [];
for (const extNode of extensionNodes) {
if (extNode.id === n.id) return;
if (
connections.find((c) => c.source === n.id && c.target === extNode.id)
) {
return;
}
if (
connections.find(
(c) => c.source === relatedNode.id && c.target === n.id
)
connections.find((c) => c.source === extNode.id && c.target === n.id)
) {
return;
}
connections.push({
source: n.id,
target: relatedNode.id,
target: extNode.id,
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ export const LinesDiagram = React.forwardRef<
}
const findRelative = (a: ParserField, index: number) => {
const pn = simulatedNodes.find(
(nf) => nf.parserField.name === getTypeName(a.type.fieldType)
(nf) =>
nf.parserField.name === getTypeName(a.type.fieldType) &&
!isExtensionNode(nf.parserField.data.type)
);
if (!pn) {
return;
Expand Down

0 comments on commit be745d6

Please sign in to comment.