Handle no uri to share case.

This commit is contained in:
Benoit Marty
2024-06-06 09:44:57 +02:00
parent 64cb42af75
commit 767e1b4259

View File

@@ -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