Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing NullReference Exception and not updating nodes on demo site diagram #364

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading