From 2814dec3e57c51d6f33b0760ddf99c225a6f0a1a Mon Sep 17 00:00:00 2001 From: Petr Mironychev <9195189+Palm1r@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:33:13 +0100 Subject: [PATCH] fix: Improve file attachment handling - Add files to existing list instead of replacing when using attach dialog - Prevent duplicate files from being added to attachment list --- ChatView/ChatRootView.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ChatView/ChatRootView.cpp b/ChatView/ChatRootView.cpp index 898f0e5..2bbe40f 100644 --- a/ChatView/ChatRootView.cpp +++ b/ChatView/ChatRootView.cpp @@ -264,10 +264,18 @@ void ChatRootView::showAttachFilesDialog() } if (dialog.exec() == QDialog::Accepted) { - QStringList filePaths = dialog.selectedFiles(); - if (!filePaths.isEmpty()) { - m_attachmentFiles = filePaths; - emit attachmentFilesChanged(); + QStringList newFilePaths = dialog.selectedFiles(); + if (!newFilePaths.isEmpty()) { + bool filesAdded = false; + for (const QString &filePath : newFilePaths) { + if (!m_attachmentFiles.contains(filePath)) { + m_attachmentFiles.append(filePath); + filesAdded = true; + } + } + if (filesAdded) { + emit attachmentFilesChanged(); + } } } }