From 7d620cd89ad301c137adf3ff1212fb56604ddbe3 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 1 May 2023 20:43:14 -0400 Subject: [PATCH] BugFix for now showing the error message when the phone can't open the file --- .../amethyst/ui/actions/NewMediaModel.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaModel.kt index 86fd92b32..880192257 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaModel.kt @@ -61,11 +61,13 @@ open class NewMediaModel : ViewModel() { contentResolver.openInputStream(uri)?.use { createNIP95Record(it.readBytes(), contentType, description) } - ?: viewModelScope.launch { - imageUploadingError.emit("Failed to upload the image / video") - isUploadingImage = false - uploadingPercentage.value = 0.00f - uploadingDescription.value = null + ?: run { + viewModelScope.launch { + imageUploadingError.emit("Failed to upload the image / video") + isUploadingImage = false + uploadingPercentage.value = 0.00f + uploadingDescription.value = null + } } } else { uploadingPercentage.value = 0.1f