From 767e1b42596f4e3ed609fa2011b868d7182d9d7c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 6 Jun 2024 09:44:57 +0200 Subject: [PATCH] Handle no uri to share case. --- .../features/share/impl/SharePresenter.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) 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