Media: handle PR review remarks
This commit is contained in:
parent
c72ecc4807
commit
b2a66ddafe
6 changed files with 8 additions and 9 deletions
|
|
@ -36,5 +36,5 @@ interface MatrixMediaLoader {
|
|||
* @param mimeType: optional mime type
|
||||
* @return a [Result] of [MediaFile]
|
||||
*/
|
||||
suspend fun loadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile>
|
||||
suspend fun downloadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class RustMediaLoader(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun loadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile> =
|
||||
override suspend fun downloadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile> =
|
||||
withContext(dispatchers.io) {
|
||||
runCatching {
|
||||
source.toRustMediaSource().use { mediaSource ->
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class FakeMediaLoader : MatrixMediaLoader {
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun loadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile> {
|
||||
override suspend fun downloadMediaFile(source: MediaSource, mimeType: String?): Result<MediaFile> {
|
||||
delay(FAKE_DELAY_IN_MS)
|
||||
return if (shouldFail) {
|
||||
Result.failure(RuntimeException())
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ internal class CoilMediaFetcher(
|
|||
override suspend fun fetch(): FetchResult? {
|
||||
return loadMedia()
|
||||
.map { data ->
|
||||
ByteBuffer.wrap(data)
|
||||
}.map { byteBuffer ->
|
||||
val byteBuffer = ByteBuffer.wrap(data)
|
||||
imageLoader.components.newFetcher(byteBuffer, options, imageLoader)?.first?.fetch()
|
||||
}.getOrThrow()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue