mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-02 11:40:00 +00:00
[Cleanup] Remove redundant code (#906)
Removes a now-redundant workaround from LinkConnector.
This commit is contained in:
@@ -274,7 +274,7 @@ export class Reroute implements Positionable, LinkSegment, Serialisable<Serialis
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the first input slot for links or floating links passing through this reroute.
|
||||
* Finds the inputs and nodes for links or floating links passing through this reroute.
|
||||
*/
|
||||
findTargetInputs(): { node: LGraphNode, input: INodeInputSlot, inputIndex: number, link: LLink }[] | undefined {
|
||||
const network = this.#network.deref()
|
||||
|
||||
@@ -409,14 +409,10 @@ export class LinkConnector {
|
||||
}
|
||||
}
|
||||
|
||||
// Flat map and filter before any connections are re-created
|
||||
const better = this.renderLinks
|
||||
.flatMap(renderLink => results.map(result => ({ renderLink, result })))
|
||||
.filter(({ renderLink, result }) => renderLink.toType === "input" && canConnectInputLinkToReroute(renderLink, result.node, result.input, reroute))
|
||||
|
||||
for (const { renderLink, result } of better) {
|
||||
if (renderLink.toType !== "input") continue
|
||||
// Filter before any connections are re-created
|
||||
const filtered = results.filter(result => renderLink.toType === "input" && canConnectInputLinkToReroute(renderLink, result.node, result.input, reroute))
|
||||
|
||||
for (const result of filtered) {
|
||||
renderLink.connectToRerouteInput(reroute, result, this.events, originalReroutes)
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export class ToInputRenderLink implements RenderLink {
|
||||
{
|
||||
node: inputNode,
|
||||
input,
|
||||
link: existingLink,
|
||||
link,
|
||||
}: { node: LGraphNode, input: INodeInputSlot, link: LLink },
|
||||
events: LinkConnectorEventTarget,
|
||||
originalReroutes: Reroute[],
|
||||
@@ -65,7 +65,7 @@ export class ToInputRenderLink implements RenderLink {
|
||||
// Set the parentId of the reroute we dropped on, to the reroute we dragged from
|
||||
reroute.parentId = fromReroute?.id
|
||||
|
||||
const newLink = outputNode.connectSlots(fromSlot, inputNode, input, existingLink.parentId)
|
||||
const newLink = outputNode.connectSlots(fromSlot, inputNode, input, link.parentId)
|
||||
|
||||
// Connecting from the final reroute of a floating reroute chain
|
||||
if (floatingTerminus) fromReroute.removeAllFloatingLinks()
|
||||
@@ -74,14 +74,14 @@ export class ToInputRenderLink implements RenderLink {
|
||||
for (const reroute of originalReroutes) {
|
||||
if (reroute.id === fromReroute?.id) break
|
||||
|
||||
reroute.removeLink(existingLink)
|
||||
reroute.removeLink(link)
|
||||
if (reroute.totalLinks === 0) {
|
||||
if (existingLink.isFloating) {
|
||||
if (link.isFloating) {
|
||||
// Cannot float from both sides - remove
|
||||
reroute.remove()
|
||||
} else {
|
||||
// Convert to floating
|
||||
const cl = existingLink.toFloating("output", reroute.id)
|
||||
const cl = link.toFloating("output", reroute.id)
|
||||
this.network.addFloatingLink(cl)
|
||||
reroute.floating = { slotType: "output" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user