mirror of
https://github.com/jcreek/OpenNetworkDiagram.git
synced 2026-07-12 18:43:44 +00:00
fix(#5): avoid clobbering conflicting reciprocal port connections
This commit is contained in:
@@ -113,19 +113,30 @@ function ensureReciprocalConnections(data: NetworkData) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const targetPort = findPort(targetOwner, port.connectedTo.port);
|
||||
if (!targetPort) {
|
||||
delete port.connectedTo;
|
||||
continue;
|
||||
}
|
||||
const targetPort = findPort(targetOwner, port.connectedTo.port);
|
||||
if (!targetPort) {
|
||||
delete port.connectedTo;
|
||||
continue;
|
||||
}
|
||||
|
||||
targetPort.connectedTo = {
|
||||
device: owner.name,
|
||||
port: port.portName
|
||||
};
|
||||
const expectedReciprocal = {
|
||||
device: owner.name,
|
||||
port: port.portName
|
||||
};
|
||||
if (!targetPort.connectedTo) {
|
||||
targetPort.connectedTo = expectedReciprocal;
|
||||
continue;
|
||||
}
|
||||
|
||||
const hasMatchingReciprocal =
|
||||
equalsIgnoreCase(targetPort.connectedTo.device, owner.name) &&
|
||||
equalsIgnoreCase(targetPort.connectedTo.port, port.portName);
|
||||
if (hasMatchingReciprocal) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearInboundReferences(data: NetworkData, predicate: (connection: Port['connectedTo']) => boolean) {
|
||||
for (const owner of allOwners(data)) {
|
||||
|
||||
Reference in New Issue
Block a user