diff --git a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt index 8a5ecbd421..07668a6628 100644 --- a/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt +++ b/features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt @@ -75,21 +75,25 @@ class SharePresenter @AssistedInject constructor( val result = shareIntentHandler.handleIncomingShareIntent( intent, onUris = { filesToShare -> - roomIds - .map { roomId -> - val room = matrixClient.getRoom(roomId) ?: return@map false - val mediaSender = MediaSender(preProcessor = mediaPreProcessor, room = room) - filesToShare - .map { fileToShare -> - mediaSender.sendMedia( - uri = fileToShare.uri, - mimeType = fileToShare.mimeType, - compressIfPossible = true, - ).isSuccess - } - .all { it } - } - .all { it } + if (filesToShare.isEmpty()) { + false + } else { + roomIds + .map { roomId -> + val room = matrixClient.getRoom(roomId) ?: return@map false + val mediaSender = MediaSender(preProcessor = mediaPreProcessor, room = room) + filesToShare + .map { fileToShare -> + mediaSender.sendMedia( + uri = fileToShare.uri, + mimeType = fileToShare.mimeType, + compressIfPossible = true, + ).isSuccess + } + .all { it } + } + .all { it } + } }, onPlainText = { text -> roomIds