proper finish updates collector
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Pilz.UI.Extensions;
|
||||
using Pilz.UI.Symbols;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
|
||||
@@ -15,8 +15,33 @@ internal class UpdatesCollectorFeature : PluginFunction
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is MainApiParameters p)
|
||||
new UpdatesCollectorUi().Show(p.Api.MainWindow);
|
||||
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurWorkspace.UpdateInfos 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;
|
||||
|
||||
// Path install actions
|
||||
foreach (var update in ucDialog.CurrentUpdates.List)
|
||||
{
|
||||
update.Origin.SourceTag = update.AvailableVersions[update.NewVersion].Value;
|
||||
p.Api.UpdateItem(update.Origin);
|
||||
}
|
||||
|
||||
// Create update actions
|
||||
var updateSet = new UpdateInfo();
|
||||
foreach (var update in ucDialog.CurrentUpdates.List)
|
||||
{
|
||||
updateSet.Actions.Add(new()
|
||||
{
|
||||
InheritFrom = update.Origin.Id,
|
||||
});
|
||||
}
|
||||
p.Api.CurWorkspace.UpdateInfos.Updates.Insert(0, updateSet);
|
||||
p.Api.UpdateItem(updateSet);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user