From fd0ef5de8f869bf71cc768f93f828f708387494d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=CC=81bor=20Baja=CC=81ki?= Date: Tue, 30 Mar 2021 20:35:53 +0200 Subject: [PATCH 1/2] #284: Added better solution to update list, it's only updates the necessary properties when there's a real change. --- DotNetifyLib.Core/Client/ViewState.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/DotNetifyLib.Core/Client/ViewState.cs b/DotNetifyLib.Core/Client/ViewState.cs index ae2c70b5..1dc1c220 100644 --- a/DotNetifyLib.Core/Client/ViewState.cs +++ b/DotNetifyLib.Core/Client/ViewState.cs @@ -196,8 +196,16 @@ public virtual void UpdateList(string listName, object data, string itemKeyName) { _dispatcher.InvokeAsync(() => { - listIface.Insert(i, newItem); - listIface.RemoveAt(i + 1); + foreach (var newItemProp in newItem.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) + { + var oldItemPropValue = newItemProp.GetValue(listIface[i]); + var newItemPropValue = newItemProp.GetValue(newItem); + if (!(oldItemPropValue?.Equals(newItemPropValue) == true)) + { + newItemProp.SetValue(listIface[i], newItemPropValue); + } + } + }); return; } From 40f8d97be8c4b40e7a01f69c0db3d350422514e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=CC=81bor=20Baja=CC=81ki?= Date: Tue, 30 Mar 2021 20:48:40 +0200 Subject: [PATCH 2/2] #284: Removed unnecessary line break. --- DotNetifyLib.Core/Client/ViewState.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DotNetifyLib.Core/Client/ViewState.cs b/DotNetifyLib.Core/Client/ViewState.cs index 1dc1c220..aa3600ad 100644 --- a/DotNetifyLib.Core/Client/ViewState.cs +++ b/DotNetifyLib.Core/Client/ViewState.cs @@ -205,7 +205,6 @@ public virtual void UpdateList(string listName, object data, string itemKeyName) newItemProp.SetValue(listIface[i], newItemPropValue); } } - }); return; }