Fix corruption of selected link highlights (#897)

Occurred when deselecting one side of a link when both sides were
selected.
This commit is contained in:
filtered
2025-04-07 00:30:22 +10:00
committed by GitHub
parent 7360e09172
commit 6cafeeff19
4 changed files with 37 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ import type {
LinkSegment,
ReadonlyLinkNetwork,
} from "./interfaces"
import type { NodeId } from "./LGraphNode"
import type { LGraphNode, NodeId } from "./LGraphNode"
import type { Reroute, RerouteId } from "./Reroute"
import type { Serialisable, SerialisableLLink } from "./types/serialisation"
@@ -156,6 +156,28 @@ export class LLink implements LinkSegment, Serialisable<SerialisableLLink> {
?.findNextReroute(rerouteId)
}
/**
* Gets the origin node of a link.
* @param network The network to search
* @param linkId The ID of the link to get the origin node of
* @returns The origin node of the link, or `undefined` if the link is not found or the origin node is not found
*/
static getOriginNode(network: Pick<ReadonlyLinkNetwork, "getNodeById" | "links">, linkId: LinkId): LGraphNode | undefined {
const id = network.links.get(linkId)?.origin_id
return network.getNodeById(id) ?? undefined
}
/**
* Gets the target node of a link.
* @param network The network to search
* @param linkId The ID of the link to get the target node of
* @returns The target node of the link, or `undefined` if the link is not found or the target node is not found
*/
static getTargetNode(network: Pick<ReadonlyLinkNetwork, "getNodeById" | "links">, linkId: LinkId): LGraphNode | undefined {
const id = network.links.get(linkId)?.target_id
return network.getNodeById(id) ?? undefined
}
configure(o: LLink | SerialisedLLinkArray) {
if (Array.isArray(o)) {
this.id = o[0]