MCPcopy Create free account
hub / github.com/SolarLune/masterplan / ReceiveMessage

Method ReceiveMessage

contents.go:431–487  ·  view source on GitHub ↗
(msg *Message)

Source from the content-addressed store, hash-verified

429}
430
431func (cc *CheckboxContents) ReceiveMessage(msg *Message) {
432 if msg.Type == MessageStacksUpdated {
433 cc.ParentOf = cc.Card.Stack.Children()
434 } else if msg.Type == MessageLinkCreated || msg.Type == MessageLinkDeleted || msg.Type == MessageContentSwitched {
435 cc.Linked = []*Card{}
436
437 isCycle := func(card *Card) bool {
438
439 checked := map[*Card]bool{
440 card: true,
441 }
442 toCheck := []*Card{}
443
444 for _, link := range card.Links {
445 if link.End != card {
446 toCheck = append(toCheck, link.End)
447 }
448 }
449
450 for len(toCheck) > 0 {
451
452 top := toCheck[0]
453 toCheck = toCheck[1:]
454
455 if _, exists := checked[top]; !exists {
456
457 checked[top] = true
458
459 for _, link := range top.Links {
460
461 if link.End != top {
462 toCheck = append(toCheck, link.End)
463 }
464
465 }
466
467 } else {
468 return true
469 }
470
471 }
472
473 return false
474
475 }
476
477 for _, link := range cc.Card.Links {
478
479 if link.End != cc.Card && !isCycle(link.End) && link.End.Numberable() {
480 cc.Linked = append(cc.Linked, link.End)
481 }
482
483 }
484 // } else if msg.Type == MessageCardDeserialized {
485 // cc.URLButtons.ScanText(cc.Card.Properties.Get("description").AsString())
486 }
487}
488

Callers

nothing calls this directly

Calls 2

ChildrenMethod · 0.80
NumberableMethod · 0.80

Tested by

no test coverage detected