private void MergeData([NotNull] AppList remoteAppList, bool resetClient)
{
#region Sanity checks
if (remoteAppList == null) throw new ArgumentNullException(nameof(remoteAppList));
#endregion
var toAdd = new List<AppEntry>();
var toRemove = new List<AppEntry>();
if (resetClient)
{
Merge.TwoWay(
theirs: remoteAppList.Entries,
mine: AppList.Entries,
added: toAdd, removed: toRemove);
}
else
{
Merge.ThreeWay(
reference: _appListLastSync.Entries,
theirs: remoteAppList.Entries,
mine: AppList.Entries,
added: toAdd, removed: toRemove);
}
Handler.RunTask(new SimpleTask(Resources.ApplyingChanges, () =>
{
toRemove.ApplyWithRollback(RemoveAppInternal, AddAppHelper);
toAdd.ApplyWithRollback(AddAppHelper, RemoveAppInternal);
}));
}