remove redundant connectionLookup entries

This commit is contained in:
peterkogo
2025-01-07 14:18:05 +01:00
parent b601d385f3
commit b2d1844c0f
6 changed files with 37 additions and 11 deletions
@@ -116,7 +116,7 @@
$: if (onconnect || ondisconnect) {
// connectionLookup is not reactive, so we use edges to get notified about updates
$edges;
connections = $connectionLookup.get(`${nodeId}-${type}-${id || null}`);
connections = $connectionLookup.get(`${nodeId}-${type}${id ? `-${id}` : ''}`);
}
$: {
@@ -22,7 +22,7 @@ const initialConnections: HandleConnection[] = [];
* @param param.id - the handle id (this is only needed if the node has multiple handles of the same type)
* @returns an array with connections
*/
export function useHandleConnections({ type, nodeId, id = null }: useHandleConnectionsParams) {
export function useHandleConnections({ type, nodeId, id }: useHandleConnectionsParams) {
const { edges, connectionLookup } = useStore();
console.warn(
@@ -37,7 +37,7 @@ export function useHandleConnections({ type, nodeId, id = null }: useHandleConne
return derived(
[edges, connectionLookup],
([, connectionLookup], set) => {
const nextConnections = connectionLookup.get(`${currentNodeId}-${type}-${id || null}`);
const nextConnections = connectionLookup.get(`${currentNodeId}-${type}${id ? `-${id}` : ''}`);
if (!areConnectionMapsEqual(nextConnections, prevConnections)) {
prevConnections = nextConnections;