Skip to content

Commit

Permalink
Fix: Fixed issue where the extract button on the toolbar was disabled…
Browse files Browse the repository at this point in the history
… in archives (#12144)
  • Loading branch information
hishitetsu authored Apr 21, 2023
1 parent bdc1b68 commit 47700ae
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Files.App/Actions/Content/Archives/DecompressArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using Files.App.Contexts;
using Files.App.Extensions;
using Files.App.Helpers;
using Files.Backend.Helpers;
using System.ComponentModel;
using System.IO;
using System.Threading.Tasks;

namespace Files.App.Actions
Expand All @@ -19,8 +21,9 @@ internal class DecompressArchive : BaseUIAction, IAction
public HotKey HotKey { get; } = new(Keys.E, KeyModifiers.Ctrl);

public override bool IsExecutable =>
IsContextPageTypeAdaptedToCommand() &&
ArchiveHelpers.CanDecompress(context.SelectedItems) &&
(IsContextPageTypeAdaptedToCommand() &&
ArchiveHelpers.CanDecompress(context.SelectedItems)
|| CanDecompressInsideArchive()) &&
UIHelpers.CanShowDialog;

public DecompressArchive()
Expand All @@ -40,13 +43,20 @@ and not ContentPageTypes.ZipFolder
and not ContentPageTypes.None;
}

private bool CanDecompressInsideArchive()
{
return context.PageType is ContentPageTypes.ZipFolder &&
!context.HasSelection &&
context.Folder is not null &&
FileExtensionHelpers.IsZipFile(Path.GetExtension(context.Folder.ItemPath));
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(IContentPageContext.SelectedItems):
if (IsContextPageTypeAdaptedToCommand())
OnPropertyChanged(nameof(IsExecutable));
OnPropertyChanged(nameof(IsExecutable));
break;
}
}
Expand Down

0 comments on commit 47700ae

Please sign in to comment.