From 18b4f56158ce67b39f23aad52bb79b530c9f966d Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Thu, 25 Sep 2025 21:09:00 -0700 Subject: [PATCH] refactor candidatefromnodetarget --- .../composables/useSlotLinkInteraction.ts | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts b/src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts index 0704b7121b..ec08b7ad94 100644 --- a/src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts +++ b/src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts @@ -142,27 +142,27 @@ export function useSlotLinkInteraction({ if (!firstLink) return null const connectingTo = adapter.linkConnector.state.connectingTo - if (connectingTo === 'input') { - const res = node.findInputByType(firstLink.fromSlot.type) - const index = res?.index - if (index == null) return null - const key = getSlotKey(String(nodeId), index, true) - const layout = layoutStore.getSlotLayout(key) - if (!layout) return null - const compatible = adapter.isInputValidDrop(nodeId, index) - if (!compatible) return null - return { layout, compatible: true } - } else if (connectingTo === 'output') { - const res = node.findOutputByType(firstLink.fromSlot.type) - const index = res?.index - if (index == null) return null - const key = getSlotKey(String(nodeId), index, false) - const layout = layoutStore.getSlotLayout(key) - if (!layout) return null - const compatible = adapter.isOutputValidDrop(nodeId, index) - if (!compatible) return null - return { layout, compatible: true } - } + if (connectingTo !== 'input' && connectingTo !== 'output') return null + + const isInput = connectingTo === 'input' + const slotType = firstLink.fromSlot.type + + const res = isInput + ? node.findInputByType(slotType) + : node.findOutputByType(slotType) + + const index = res?.index + if (index == null) return null + + const key = getSlotKey(String(nodeId), index, isInput) + const layout = layoutStore.getSlotLayout(key) + if (!layout) return null + + const compatible = isInput + ? adapter.isInputValidDrop(nodeId, index) + : adapter.isOutputValidDrop(nodeId, index) + + return compatible ? { layout, compatible: true } : null return null }