Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed the dialog may not be shown when undoing to delete items #11201

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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