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
This commit is contained in:
Petr Mironychev 2025-01-21 11:33:13 +01:00
parent 1b86b60de8
commit 2814dec3e5

View File

@ -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();
}
}
}
}