desktop: fix drag-and-drop videos attached as files (#7015)

onFilesAttached classified URIs by isImage only, so videos fell through
to processPickedFile and were attached as generic files. processPickedMedia
already handles video correctly; the classifier above it just never
reached that branch. Recognise videos as media inline using getFileName.
This commit is contained in:
Narasimha-sc authored and GitHub committed 2026-06-08 00:02:54 +01:00
1 parent 7548fdae3b
commit 7c5406a4e9
2 files changed
+54 -4

No files matched your search

@@ -288,16 +288,22 @@ expect fun AttachmentSelection(
)
fun MutableState<ComposeState>.onFilesAttached(uris: List<URI>) {
val groups = uris.groupBy { isImage(it) }
val images = groups[true] ?: emptyList()
val groups = uris.groupBy { isImage(it) || isVideoUri(it) }
val media = groups[true] ?: emptyList()
val files = groups[false] ?: emptyList()
if (images.isNotEmpty()) {
CoroutineScope(Dispatchers.IO).launch { processPickedMedia(images, null) }
if (media.isNotEmpty()) {
CoroutineScope(Dispatchers.IO).launch { processPickedMedia(media, null) }
} else if (files.isNotEmpty()) {
processPickedFile(uris.first(), null)
}
}
private fun isVideoUri(uri: URI): Boolean {
val name = getFileName(uri)?.lowercase() ?: return false
return name.endsWith(".mov") || name.endsWith(".avi") || name.endsWith(".mp4") ||
name.endsWith(".mpg") || name.endsWith(".mpeg") || name.endsWith(".mkv")
}
fun MutableState<ComposeState>.processPickedFile(uri: URI?, text: String?) {
if (uri != null) {
val fileSize = getFileSize(uri)