Merge pull request #429 from Moonlight-Panel/v2_ShowFilesWhichWillGetDeleted

Popup listing some of the files which will be deleted
This commit is contained in:
Masu Baumgartner
2024-06-18 23:54:59 +02:00
committed by GitHub

View File

@@ -15,7 +15,36 @@ public class DeleteSelectionAction : IFileManagerSelectionAction
var alertService = provider.GetRequiredService<AlertService>(); var alertService = provider.GetRequiredService<AlertService>();
var toastService = provider.GetRequiredService<ToastService>(); var toastService = provider.GetRequiredService<ToastService>();
if(!await alertService.YesNo($"Do you really want to delete {entries.Length} item(s)?")) var folderEmoji = "\ud83d\udcc1";
var fileEmoji = "\ud83d\udcc4";
var showFolderCount = 3;
var showFileCount = 6;
var folderCount = entries.Count(x => x.IsDirectory);
var fileCount = entries.Count(x => x.IsFile);
// Construct file list
var fileList = "";
foreach (var folder in entries.Where(x => x.IsDirectory).Take(showFolderCount))
{
fileList += folderEmoji + " " + folder.Name + "\n";
}
if (folderCount > showFolderCount)
fileList += "And " + (folderCount - showFolderCount) + " more folders... \n\n";
foreach (var file in entries.Where(x => x.IsFile).Take(showFileCount))
{
fileList += fileEmoji + " " + file.Name + "\n";
}
if (fileCount > showFileCount)
fileList += "And " + (fileCount - showFileCount) + " more files...";
if(!await alertService.YesNo($"Do you really want to delete {folderCount + fileCount} item(s)? \n\n" + fileList))
return; return;
await toastService.CreateProgress("fileManagerSelectionDelete", "Deleting items"); await toastService.CreateProgress("fileManagerSelectionDelete", "Deleting items");