@@ -142,27 +142,27 @@ export function useSlotLinkInteraction({
142
142
if ( ! firstLink ) return null
143
143
const connectingTo = adapter . linkConnector . state . connectingTo
144
144
145
- if ( connectingTo === 'input' ) {
146
- const res = node . findInputByType ( firstLink . fromSlot . type )
147
- const index = res ?. index
148
- if ( index == null ) return null
149
- const key = getSlotKey ( String ( nodeId ) , index , true )
150
- const layout = layoutStore . getSlotLayout ( key )
151
- if ( ! layout ) return null
152
- const compatible = adapter . isInputValidDrop ( nodeId , index )
153
- if ( ! compatible ) return null
154
- return { layout , compatible : true }
155
- } else if ( connectingTo === 'output' ) {
156
- const res = node . findOutputByType ( firstLink . fromSlot . type )
157
- const index = res ?. index
158
- if ( index == null ) return null
159
- const key = getSlotKey ( String ( nodeId ) , index , false )
160
- const layout = layoutStore . getSlotLayout ( key )
161
- if ( ! layout ) return null
162
- const compatible = adapter . isOutputValidDrop ( nodeId , index )
163
- if ( ! compatible ) return null
164
- return { layout , compatible : true }
165
- }
145
+ if ( connectingTo !== 'input' && connectingTo !== 'output' ) return null
146
+
147
+ const isInput = connectingTo === 'input'
148
+ const slotType = firstLink . fromSlot . type
149
+
150
+ const res = isInput
151
+ ? node . findInputByType ( slotType )
152
+ : node . findOutputByType ( slotType )
153
+
154
+ const index = res ?. index
155
+ if ( index == null ) return null
156
+
157
+ const key = getSlotKey ( String ( nodeId ) , index , isInput )
158
+ const layout = layoutStore . getSlotLayout ( key )
159
+ if ( ! layout ) return null
160
+
161
+ const compatible = isInput
162
+ ? adapter . isInputValidDrop ( nodeId , index )
163
+ : adapter . isOutputValidDrop ( nodeId , index )
164
+
165
+ return compatible ? { layout , compatible : true } : null
166
166
167
167
return null
168
168
}
0 commit comments