Skip to content

Fix: Fixed issue where confirm to delete would show even with the setting turned off #10893

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

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 @@ -116,10 +116,10 @@ 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 && ((!permanently && !canBeSentToBin) || UserSettingsService.PreferencesSettingsService.ShowConfirmDeleteDialog)) // Check if the setting to show a confirmation dialog is on
if (showDialog && UserSettingsService.PreferencesSettingsService.ShowConfirmDeleteDialog) // Check if the setting to show a confirmation dialog is on
{
var incomingItems = new List<BaseFileSystemDialogItemViewModel>();
List<ShellFileItem> binItems = null;
List<ShellFileItem>? binItems = null;
foreach (var src in source)
{
if (recycleBinHelpers.IsPathUnderRecycleBin(src.Path))
Expand Down Expand Up @@ -147,13 +147,15 @@ public async Task<ReturnResult> DeleteItemsAsync(IEnumerable<IStorageItemWithPat
var dialogService = Ioc.Default.GetRequiredService<IDialogService>();

if (await dialogService.ShowDialogAsync(dialogViewModel) != DialogResult.Primary)
{
return ReturnResult.Cancelled; // Return if the result isn't delete
}

// Delete selected items if the result is Yes
permanently = dialogViewModel.DeletePermanently;
}
else
{
permanently |= !canBeSentToBin; // delete permanently if recycle bin is not supported
}

// post the status banner
var banner = PostBannerHelpers.PostBanner_Delete(source, returnStatus, permanently, false, 0);
Expand All @@ -169,9 +171,7 @@ public async Task<ReturnResult> DeleteItemsAsync(IEnumerable<IStorageItemWithPat
await Task.Yield();

if (!permanently && registerHistory)
{
App.HistoryWrapper.AddHistory(history);
}
var itemsDeleted = history?.Source.Count ?? 0;

source.ForEach(x => App.JumpList.RemoveFolder(x.Path)); // Remove items from jump list
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/RecycleBinHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
return contentDialog;
}

public async Task<bool> HasRecycleBin(string path)
public async Task<bool> HasRecycleBin(string? path)
{
if (string.IsNullOrEmpty(path) || path.StartsWith(@"\\?\", StringComparison.Ordinal))
return false;
Expand Down
1 change: 0 additions & 1 deletion src/Files.Shared/Enums/CopyEngineResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public static FileSystemStatusCode Convert(int? hres)
CopyEngineResult.COPYENGINE_E_NET_DISCONNECT_DEST => FileSystemStatusCode.NotFound,
CopyEngineResult.COPYENGINE_E_NET_DISCONNECT_SRC => FileSystemStatusCode.NotFound,
CopyEngineResult.COPYENGINE_E_CANT_REACH_SOURCE => FileSystemStatusCode.NotFound,
CopyEngineResult.COPYENGINE_E_RECYCLE_BIN_NOT_FOUND => FileSystemStatusCode.NotFound,
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_NORMAL => FileSystemStatusCode.AlreadyExists,
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_READONLY => FileSystemStatusCode.AlreadyExists,
CopyEngineResult.COPYENGINE_E_ALREADY_EXISTS_SYSTEM => FileSystemStatusCode.AlreadyExists,
Expand Down