Skip to content

Commit

Permalink
Merge pull request #364 from K0369/bugfix/nre-on-demo-site
Browse files Browse the repository at this point in the history
Fixing NullReference Exception and not updating nodes on demo site diagram
  • Loading branch information
zHaytam authored Oct 23, 2023
2 parents eb9f37c + f1032af commit 12ea521
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,24 @@ private void OnLinkAdded(BaseLinkModel link)
link.TargetChanged += OnLinKTargetChanged;
}

private void OnLinKTargetChanged(BaseLinkModel link, Anchor? oldTarget, Anchor? newTarget)
private void OnLinKTargetChanged(BaseLinkModel link, Anchor oldTarget, Anchor newTarget)
{
if (oldTarget == null && newTarget != null) // First attach
// only refresh on the first time the link is attached
if (oldTarget is PositionAnchor
&& newTarget.Model is PortModel targetModel
&& link.IsAttached)
{
(newTarget.Model as PortModel)!.Parent.Refresh();
targetModel.Parent.Refresh();
}
}

private void OnLinkRemoved(BaseLinkModel link)
{
(link.Source.Model as PortModel)!.Parent.Refresh();
if (link.Target != null) (link.Target.Model as PortModel)!.Parent.Refresh();
if (link.Target is SinglePortAnchor anchor && anchor.Model is PortModel portModel)
{
portModel.Parent.Refresh();
}
link.TargetChanged -= OnLinKTargetChanged;
}
}

0 comments on commit 12ea521

Please sign in to comment.