Skip to content

Commit

Permalink
Merge pull request #285 from BajakiGabesz/284-update-list-optimization
Browse files Browse the repository at this point in the history
#284 update list optimization
  • Loading branch information
dsuryd authored Apr 1, 2021
2 parents 97c2504 + 40f8d97 commit 7167fac
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions DotNetifyLib.Core/Client/ViewState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,15 @@ 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 7167fac

Please sign in to comment.