Skip to content

Commit

Permalink
Ignored packages will be able to be "restored" from the context menu …
Browse files Browse the repository at this point in the history
…on the Installed Packages page
  • Loading branch information
marticliment committed Nov 14, 2024
1 parent 9d9d5fa commit 0e2e782
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/UniGetUI/Pages/SoftwarePages/InstalledPackagesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ protected override void WhenPackagesLoaded(ReloadReason reason)
}
}

protected override void WhenShowingContextMenu(IPackage package)
protected override async void WhenShowingContextMenu(IPackage package)
{
if (MenuAsAdmin is null
|| MenuInteractive is null
Expand All @@ -317,11 +317,25 @@ protected override void WhenShowingContextMenu(IPackage package)
MenuInstallationOptions.IsEnabled = !IS_LOCAL;
MenuReinstallPackage.IsEnabled = !IS_LOCAL;
MenuUninstallThenReinstall.IsEnabled = !IS_LOCAL;
MenuIgnoreUpdates.IsEnabled = !IS_LOCAL;
MenuIgnoreUpdates.IsEnabled = false; //!IS_LOCAL;
MenuSharePackage.IsEnabled = !IS_LOCAL;
MenuPackageDetails.IsEnabled = !IS_LOCAL;

MenuOpenInstallLocation.IsEnabled = package.Manager.GetPackageInstallLocation(package) is not null;
if (!IS_LOCAL)
{
if (await package.HasUpdatesIgnoredAsync())
{
MenuIgnoreUpdates.Text = CoreTools.Translate("Do not ignore updates for this package anymore");
MenuIgnoreUpdates.Icon = new FontIcon() { Glyph = "\uE77A" };
}
else
{
MenuIgnoreUpdates.Text = CoreTools.Translate("Ignore updates for this package");
MenuIgnoreUpdates.Icon = new FontIcon() { Glyph = "\uE718" };
}
MenuIgnoreUpdates.IsEnabled = true;
}
}

private async void ExportSelection_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -470,16 +484,21 @@ private void MenuUninstallThenReinstall_Invoked(object sender, RoutedEventArgs a
MainApp.Instance.AddOperationToList(new InstallPackageOperation(package, IgnoreParallelInstalls: true));

}
private void MenuIgnorePackage_Invoked(object sender, RoutedEventArgs args)
private async void MenuIgnorePackage_Invoked(object sender, RoutedEventArgs args)
{
IPackage? package = SelectedItem;
if (package is null)
{
return;
}

_ = package.AddToIgnoredUpdatesAsync();
PEInterface.UpgradablePackagesLoader.Remove(package);
if(await package.HasUpdatesIgnoredAsync())
await package.RemoveFromIgnoredUpdatesAsync();
else
{
await package.AddToIgnoredUpdatesAsync();
PEInterface.UpgradablePackagesLoader.Remove(package);
}
}

private void MenuShare_Invoked(object sender, RoutedEventArgs args)
Expand Down

0 comments on commit 0e2e782

Please sign in to comment.