From 240320696a928558ff3937515aa7e9a686bc6e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merlin=20Z=C3=B6bl?= <41567572+K0369@users.noreply.github.com> Date: Mon, 16 Oct 2023 12:01:37 +0200 Subject: [PATCH 1/5] Adding check for target being a portModel --- site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs index 835c8fdcd..2de170860 100644 --- a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs +++ b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs @@ -76,7 +76,7 @@ private void OnLinKTargetChanged(BaseLinkModel link, Anchor? oldTarget, Anchor? 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 != null && link.Target.Model is PortModel portModel) portModel.Parent.Refresh(); link.TargetChanged -= OnLinKTargetChanged; } } \ No newline at end of file From 93b154baa10ecc4e12c1ec1a60ac30475d393b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merlin=20Z=C3=B6bl?= <41567572+K0369@users.noreply.github.com> Date: Mon, 16 Oct 2023 12:02:50 +0200 Subject: [PATCH 2/5] Fixing nodes not updating on change of the link target --- site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs index 2de170860..4e5717172 100644 --- a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs +++ b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs @@ -67,7 +67,7 @@ private void OnLinkAdded(BaseLinkModel link) private void OnLinKTargetChanged(BaseLinkModel link, Anchor? oldTarget, Anchor? newTarget) { - if (oldTarget == null && newTarget != null) // First attach + if (link.IsAttached && newTarget is not null) { (newTarget.Model as PortModel)!.Parent.Refresh(); } From ff0fd5a0d07021e5cf224a57659ebdf14a37cc72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merlin=20Z=C3=B6bl?= <41567572+K0369@users.noreply.github.com> Date: Sun, 22 Oct 2023 13:53:58 +0200 Subject: [PATCH 3/5] fixing NRE of onLinkRemoved in landing showcase diagram --- site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs index 4e5717172..c78b72851 100644 --- a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs +++ b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs @@ -76,7 +76,10 @@ private void OnLinKTargetChanged(BaseLinkModel link, Anchor? oldTarget, Anchor? private void OnLinkRemoved(BaseLinkModel link) { (link.Source.Model as PortModel)!.Parent.Refresh(); - if (link.Target != null && link.Target.Model is PortModel portModel) portModel.Parent.Refresh(); + if (link.Target is SinglePortAnchor anchor && anchor.Model is PortModel portModel) + { + portModel.Parent.Refresh(); + } link.TargetChanged -= OnLinKTargetChanged; } } \ No newline at end of file From 95a9734b6a518c740114774041780da529a687fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merlin=20Z=C3=B6bl?= <41567572+K0369@users.noreply.github.com> Date: Sun, 22 Oct 2023 14:24:55 +0200 Subject: [PATCH 4/5] refactoring link target refreshing in landing showcase diagram --- .../Components/Landing/LandingShowcaseDiagram.razor.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs index c78b72851..17ffd29ba 100644 --- a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs +++ b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs @@ -67,9 +67,12 @@ private void OnLinkAdded(BaseLinkModel link) private void OnLinKTargetChanged(BaseLinkModel link, Anchor? oldTarget, Anchor? newTarget) { - if (link.IsAttached && newTarget is not null) + // 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(); } } From f1032af5db2120ec9ffeee7845559f075f3d655b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Merlin=20Z=C3=B6bl?= <41567572+K0369@users.noreply.github.com> Date: Sun, 22 Oct 2023 14:27:04 +0200 Subject: [PATCH 5/5] Demo-site: changing signature of onChange to reflect actual values --- site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs index 17ffd29ba..d2933a427 100644 --- a/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs +++ b/site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs @@ -65,7 +65,7 @@ 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) { // only refresh on the first time the link is attached if (oldTarget is PositionAnchor