move actions to separated code & add sinlge update search action
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Pilz.UI.Extensions;
|
||||
using Pilz.UI.Symbols;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
@@ -17,40 +16,10 @@ internal class UpdatesCollectorFeature : PluginFunction, IPluginFeatureProvider<
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurWorkspace.UpdateInfos is null)
|
||||
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null)
|
||||
return null;
|
||||
|
||||
// Collect updates
|
||||
var ucDialog = new UpdatesCollectorUi(p.Api.CurWorkspace.InstallInfos);
|
||||
if (!ucDialog.ShowDialog(p.Api.MainWindow).IsOk() || ucDialog.CurrentUpdates is null)
|
||||
return null;
|
||||
|
||||
// Collect versions with changes
|
||||
var updates = new List<UpdatesCollectorUi.ModUpdateInfo>();
|
||||
foreach (var update in ucDialog.CurrentUpdates.List)
|
||||
{
|
||||
if (update.Origin.SourceTag != update.AvailableVersions[update.NewVersion].Value)
|
||||
updates.Add(update);
|
||||
}
|
||||
|
||||
// Path install actions
|
||||
foreach (var update in updates)
|
||||
{
|
||||
update.Origin.SourceTag = update.AvailableVersions[update.NewVersion].Value;
|
||||
p.Api.UpdateItem(update.Origin);
|
||||
}
|
||||
|
||||
// Create update actions
|
||||
var updateSet = new UpdateInfo();
|
||||
foreach (var update in updates)
|
||||
{
|
||||
updateSet.Actions.Add(new()
|
||||
{
|
||||
InheritFrom = update.Origin.Id,
|
||||
});
|
||||
}
|
||||
p.Api.CurWorkspace.UpdateInfos.Updates.Insert(0, updateSet);
|
||||
p.Api.UpdateItem(updateSet);
|
||||
SharedFunctions.CollectUpdates(p.Api, [.. p.Api.CurWorkspace.InstallInfos.Actions]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user