Skip to content

Commit

Permalink
Allow deletion from search results. (#11655)
Browse files Browse the repository at this point in the history
  • Loading branch information
cinqmilleans authored Mar 10, 2023
1 parent 0cc8d54 commit 8d15485
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Files.App/Actions/FileSystem/DeleteItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class DeleteItemAction : ObservableObject, IAction

public HotKey HotKey { get; } = new(VirtualKey.Delete);

public bool IsExecutable => context.PageType is not ContentPageTypes.SearchResults && context.HasSelection;
public bool IsExecutable => context.HasSelection;

public DeleteItemAction()
{
Expand All @@ -38,19 +38,16 @@ public async Task ExecuteAsync()
return;

var items = context.SelectedItems.Select(item => StorageHelpers.FromPathAndType(item.ItemPath,
item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));
item.PrimaryItemAttribute is StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));

await context.ShellPage.FilesystemHelpers.DeleteItemsAsync(items, settings.DeleteConfirmationPolicy, true, true);
await context.ShellPage.FilesystemViewModel.ApplyFilesAndFoldersChangesAsync();
}

public void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(IContentPageContext.PageType):
case nameof(IContentPageContext.HasSelection):
OnPropertyChanged(nameof(IsExecutable));
break;
}
if (e.PropertyName is nameof(IContentPageContext.HasSelection))
OnPropertyChanged(nameof(IsExecutable));
}
}
}

0 comments on commit 8d15485

Please sign in to comment.