mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-14 10:53:48 +00:00
Sort attachments by folder so each folder is named once
This commit is contained in:
2 files changed
+16
-1
No files matched your search
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
var currentFolder = string.Empty;
|
var currentFolder = string.Empty;
|
||||||
foreach (var fileAttachment in this.DocumentPaths)
|
foreach (var fileAttachment in this.OrderedAttachments)
|
||||||
{
|
{
|
||||||
var folderPath = Path.GetDirectoryName(fileAttachment.FilePath);
|
var folderPath = Path.GetDirectoryName(fileAttachment.FilePath);
|
||||||
if (folderPath != currentFolder)
|
if (folderPath != currentFolder)
|
||||||
|
|||||||
@@ -73,6 +73,21 @@ public partial class ReviewAttachmentsDialog : MSGComponentBase
|
|||||||
: "border-dashed border-2 rounded-lg pa-2 mud-border-lines-default";
|
: "border-dashed border-2 rounded-lg pa-2 mud-border-lines-default";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The attachments, sorted by their folder and, within it, by their file name.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The list below starts a new heading whenever the folder changes from one attachment to the
|
||||||
|
/// next, which names every folder exactly once -- but only as long as the attachments of a
|
||||||
|
/// folder arrive together. The set behind them keeps no order of its own to guarantee that:
|
||||||
|
/// removing one attachment already scrambles it, and one attached while this dialog is open
|
||||||
|
/// lands at its end, giving its folder a second heading further down. Sorting here is what that
|
||||||
|
/// list assumes anyway.
|
||||||
|
/// </remarks>
|
||||||
|
private IEnumerable<FileAttachment> OrderedAttachments => this.DocumentPaths
|
||||||
|
.OrderBy(attachment => Path.GetDirectoryName(attachment.FilePath) ?? string.Empty, StringComparer.OrdinalIgnoreCase)
|
||||||
|
.ThenBy(attachment => attachment.FileName, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attaches what the user dropped onto this dialog and answers which files that became.
|
/// Attaches what the user dropped onto this dialog and answers which files that became.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in new issue
Block a user