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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetPort = findPort(targetOwner, port.connectedTo.port);
|
const targetPort = findPort(targetOwner, port.connectedTo.port);
|
||||||
if (!targetPort) {
|
if (!targetPort) {
|
||||||
delete port.connectedTo;
|
delete port.connectedTo;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetPort.connectedTo = {
|
const expectedReciprocal = {
|
||||||
device: owner.name,
|
device: owner.name,
|
||||||
port: port.portName
|
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) {
|
function clearInboundReferences(data: NetworkData, predicate: (connection: Port['connectedTo']) => boolean) {
|
||||||
for (const owner of allOwners(data)) {
|
for (const owner of allOwners(data)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user