MediaViewer: improve actions (save on disk and share)
This commit is contained in:
parent
89d4b81f80
commit
fa63ed1faf
7 changed files with 22 additions and 15 deletions
|
|
@ -36,5 +36,5 @@ interface MatrixMediaLoader {
|
|||
* @param mimeType: optional mime type
|
||||
* @return a [Result] of [MediaFile]
|
||||
*/
|
||||
suspend fun downloadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile>
|
||||
suspend fun downloadMediaFile(source: MediaSource, mimeType: String?, body: String?): Result<MediaFile>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,13 +59,13 @@ class RustMediaLoader(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun downloadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile> =
|
||||
override suspend fun downloadMediaFile(source: MediaSource, mimeType: String?, body: String?): Result<MediaFile> =
|
||||
withContext(dispatchers.io) {
|
||||
runCatching {
|
||||
source.toRustMediaSource().use { mediaSource ->
|
||||
val mediaFile = innerClient.getMediaFile(
|
||||
mediaSource = mediaSource,
|
||||
body = null,
|
||||
body = body,
|
||||
mimeType = mimeType ?: "application/octet-stream"
|
||||
)
|
||||
RustMediaFile(mediaFile)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class FakeMediaLoader : MatrixMediaLoader {
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun downloadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile> {
|
||||
override suspend fun downloadMediaFile(source: MediaSource, mimeType: String?, body: String?): Result<MediaFile> {
|
||||
delay(FAKE_DELAY_IN_MS)
|
||||
return if (shouldFail) {
|
||||
Result.failure(RuntimeException())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue