Skip to content

Commit

Permalink
Fix: Fixed the dialog may not be shown when undoing to delete items (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hishitetsu authored Feb 7, 2023
1 parent d9cc70c commit 69de869
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public async Task<ReturnResult> DeleteItemsAsync(IEnumerable<IStorageItemWithPat
var deleteFromRecycleBin = source.Select(item => item.Path).Any(path => RecycleBinHelpers.IsPathUnderRecycleBin(path));
var canBeSentToBin = !deleteFromRecycleBin && await RecycleBinHelpers.HasRecycleBin(source.FirstOrDefault()?.Path);

if (showDialog && UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog) // Check if the setting to show a confirmation dialog is on
if (showDialog)
{
var incomingItems = new List<BaseFileSystemDialogItemViewModel>();
List<ShellFileItem>? binItems = null;
Expand Down Expand Up @@ -258,8 +258,7 @@ public async Task<ReturnResult> PerformOperationTypeAsync(DataPackageOperation o
}
if (destination.StartsWith(CommonPaths.RecycleBinPath, StringComparison.Ordinal))
{
showDialog |= UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog;
return await RecycleItemsFromClipboard(packageView, destination, showDialog, registerHistory);
return await RecycleItemsFromClipboard(packageView, destination, UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog, registerHistory);
}
else if (operation.HasFlag(DataPackageOperation.Copy))
{
Expand Down
6 changes: 5 additions & 1 deletion src/Files.App/Helpers/RecycleBinHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Extensions;
using Files.App.Filesystem;
using Files.App.Shell;
using Files.Backend.Services.Settings;
using Files.Shared;
using Files.Shared.Enums;
using Microsoft.UI.Xaml.Controls;
Expand All @@ -20,6 +22,8 @@ public static class RecycleBinHelpers

private static readonly Regex recycleBinPathRegex = new(@"^[A-Z]:\\\$Recycle\.Bin\\", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

private static readonly IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();

#endregion Private Members

public static async Task<List<ShellFileItem>> EnumerateRecycleBin()
Expand Down Expand Up @@ -169,7 +173,7 @@ public static async Task DeleteItem(IShellPage associatedInstance)
var items = associatedInstance.SlimContentPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType(
item.ItemPath,
item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));
await associatedInstance.FilesystemHelpers.DeleteItemsAsync(items, true, false, true);
await associatedInstance.FilesystemHelpers.DeleteItemsAsync(items, userSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog, false, true);
}
}
}
4 changes: 2 additions & 2 deletions src/Files.App/Views/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
var items = SlimContentPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType(
item.ItemPath,
item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));
await FilesystemHelpers.DeleteItemsAsync(items, true, true, true);
await FilesystemHelpers.DeleteItemsAsync(items, UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog, true, true);
}

break;
Expand Down Expand Up @@ -758,7 +758,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
var items = SlimContentPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType(
item.ItemPath,
item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));
await FilesystemHelpers.DeleteItemsAsync(items, true, false, true);
await FilesystemHelpers.DeleteItemsAsync(items, UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog, false, true);
}

break;
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
var items = SlimContentPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType(
item.ItemPath,
item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));
await FilesystemHelpers.DeleteItemsAsync(items, true, true, true);
await FilesystemHelpers.DeleteItemsAsync(items, UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog, true, true);
}

break;
Expand Down Expand Up @@ -761,7 +761,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
var items = SlimContentPage.SelectedItems.ToList().Select((item) => StorageHelpers.FromPathAndType(
item.ItemPath,
item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory));
await FilesystemHelpers.DeleteItemsAsync(items, true, false, true);
await FilesystemHelpers.DeleteItemsAsync(items, UserSettingsService.FoldersSettingsService.ShowConfirmDeleteDialog, false, true);
}

break;
Expand Down

0 comments on commit 69de869

Please sign in to comment.