Skip to content

Commit

Permalink
dsuryd#284: Added better solution to update list, it's only updates t…
Browse files Browse the repository at this point in the history
…he necessary properties when there's a real change.
  • Loading branch information
BajakiGabesz committed Mar 30, 2021
1 parent e1aeb1c commit fd0ef5d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions DotNetifyLib.Core/Client/ViewState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit fd0ef5d

Please sign in to comment.