File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,19 @@ struct KPBoard: Identifiable {
5151 self . edges. removeAll { edge in
5252 edge. id == edgeID
5353 }
54+ self . checkIsLinked ( )
55+ }
56+
57+ public mutating func checkIsLinked( ) {
58+ self . nodes. enumerated ( ) . forEach { index, node in
59+ node. inputPoints. enumerated ( ) . forEach { inputPointIndex, inputPoint in
60+ if self . edges. contains ( where: { $0. sinkID == inputPoint. id } ) {
61+ self . nodes [ index] . inputPoints [ inputPointIndex] . isLinked = true
62+ } else {
63+ self . nodes [ index] . inputPoints [ inputPointIndex] . isLinked = false
64+ }
65+ }
66+ }
5467 }
5568
5669 public mutating func addNode( _ node: KPNode ) {
Original file line number Diff line number Diff line change @@ -300,19 +300,19 @@ extension KPBoardDocument {
300300
301301 withAnimation {
302302 self . board. removeEdge ( edgeID)
303+ self . board. checkIsLinked ( )
303304 }
304305
305306 undoManager? . registerUndo ( withTarget: self ) { doc in
306307 doc. replaceEdges ( oldEdges, undoManager: undoManager)
307-
308-
309308 }
310309 }
311310
312311 func replaceEdges( _ edges: [ KPEdge ] , undoManager: UndoManager ? , animation: Animation ? = . default) {
313312 let oldEdges = self . board. edges
314313
315314 self . board. edges = edges
315+ self . board. checkIsLinked ( )
316316
317317 undoManager? . registerUndo ( withTarget: self ) { doc in
318318 doc. replaceEdges ( oldEdges, undoManager: undoManager, animation: animation)
You canβt perform that action at this time.
0 commit comments