Saved Counts in a variable

This commit is contained in:
Moritz Deiaco
2024-06-14 19:16:53 +02:00
parent a12e2be0e7
commit efe37d2dd7

View File

@@ -20,6 +20,9 @@ public class DeleteSelectionAction : IFileManagerSelectionAction
var showFolderCount = 3; var showFolderCount = 3;
var showFileCount = 6; var showFileCount = 6;
var folderCount = entries.Count(x => x.IsDirectory);
var fileCount = entries.Count(x => x.IsFile);
// Construct file list // Construct file list
var fileList = ""; var fileList = "";
@@ -29,19 +32,19 @@ public class DeleteSelectionAction : IFileManagerSelectionAction
fileList += folderEmoji + " " + folder.Name + "\n"; fileList += folderEmoji + " " + folder.Name + "\n";
} }
if (entries.Where(x => x.IsDirectory).ToArray().Length > showFolderCount) if (folderCount > showFolderCount)
fileList += "And " + (entries.Where(x => x.IsDirectory).ToArray().Length - showFolderCount) + " more folders... \n\n"; fileList += "And " + (folderCount - showFolderCount) + " more folders... \n\n";
foreach (var file in entries.Where(x => x.IsFile).Take(showFileCount)) foreach (var file in entries.Where(x => x.IsFile).Take(showFileCount))
{ {
fileList += fileEmoji + " " + file.Name + "\n"; fileList += fileEmoji + " " + file.Name + "\n";
} }
if (entries.Where(x => x.IsFile).ToArray().Length > showFileCount) if (fileCount > showFileCount)
fileList += "And " + (entries.Where(x => x.IsFile).ToArray().Length - showFileCount) + " more files..."; fileList += "And " + (fileCount - showFileCount) + " more files...";
if(!await alertService.YesNo($"Do you really want to delete {entries.Length} item(s)? \n\n" + fileList)) 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");