From a12e2be0e7e9a0929ec8b119e953d8aa17c382d0 Mon Sep 17 00:00:00 2001 From: Moritz Deiaco Date: Fri, 14 Jun 2024 11:13:47 +0200 Subject: [PATCH 1/2] Now, the popup is listing some of the files which will be deleted --- .../Implementations/DeleteSelectionAction.cs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Moonlight/Features/FileManager/Implementations/DeleteSelectionAction.cs b/Moonlight/Features/FileManager/Implementations/DeleteSelectionAction.cs index fbc0142f..b5bb46d6 100644 --- a/Moonlight/Features/FileManager/Implementations/DeleteSelectionAction.cs +++ b/Moonlight/Features/FileManager/Implementations/DeleteSelectionAction.cs @@ -14,8 +14,34 @@ public class DeleteSelectionAction : IFileManagerSelectionAction { var alertService = provider.GetRequiredService(); var toastService = provider.GetRequiredService(); + + var folderEmoji = "\ud83d\udcc1"; + var fileEmoji = "\ud83d\udcc4"; + + var showFolderCount = 3; + var showFileCount = 6; - if(!await alertService.YesNo($"Do you really want to delete {entries.Length} item(s)?")) + // Construct file list + var fileList = ""; + + foreach (var folder in entries.Where(x => x.IsDirectory).Take(showFolderCount)) + { + fileList += folderEmoji + " " + folder.Name + "\n"; + } + + if (entries.Where(x => x.IsDirectory).ToArray().Length > showFolderCount) + fileList += "And " + (entries.Where(x => x.IsDirectory).ToArray().Length - showFolderCount) + " more folders... \n\n"; + + foreach (var file in entries.Where(x => x.IsFile).Take(showFileCount)) + { + fileList += fileEmoji + " " + file.Name + "\n"; + } + + if (entries.Where(x => x.IsFile).ToArray().Length > showFileCount) + fileList += "And " + (entries.Where(x => x.IsFile).ToArray().Length - showFileCount) + " more files..."; + + + if(!await alertService.YesNo($"Do you really want to delete {entries.Length} item(s)? \n\n" + fileList)) return; await toastService.CreateProgress("fileManagerSelectionDelete", "Deleting items"); From efe37d2dd716b08965e1a80735506ded5eca9a7d Mon Sep 17 00:00:00 2001 From: Moritz Deiaco Date: Fri, 14 Jun 2024 19:16:53 +0200 Subject: [PATCH 2/2] Saved Counts in a variable --- .../Implementations/DeleteSelectionAction.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Moonlight/Features/FileManager/Implementations/DeleteSelectionAction.cs b/Moonlight/Features/FileManager/Implementations/DeleteSelectionAction.cs index b5bb46d6..c63c4e57 100644 --- a/Moonlight/Features/FileManager/Implementations/DeleteSelectionAction.cs +++ b/Moonlight/Features/FileManager/Implementations/DeleteSelectionAction.cs @@ -20,6 +20,9 @@ public class DeleteSelectionAction : IFileManagerSelectionAction 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 = ""; @@ -29,19 +32,19 @@ public class DeleteSelectionAction : IFileManagerSelectionAction fileList += folderEmoji + " " + folder.Name + "\n"; } - if (entries.Where(x => x.IsDirectory).ToArray().Length > showFolderCount) - fileList += "And " + (entries.Where(x => x.IsDirectory).ToArray().Length - showFolderCount) + " more folders... \n\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 (entries.Where(x => x.IsFile).ToArray().Length > showFileCount) - fileList += "And " + (entries.Where(x => x.IsFile).ToArray().Length - showFileCount) + " more files..."; + if (fileCount > showFileCount) + 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; await toastService.CreateProgress("fileManagerSelectionDelete", "Deleting items");