From 884358b374702597cf2111ab5788479fd0b408c5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 7 Apr 2021 13:47:20 +0200 Subject: [PATCH] Small cleanup --- .../roomprofile/uploads/RoomUploadsViewModel.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/uploads/RoomUploadsViewModel.kt b/vector/src/main/java/im/vector/app/features/roomprofile/uploads/RoomUploadsViewModel.kt index bae4847f7e..1d6b056816 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/uploads/RoomUploadsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/uploads/RoomUploadsViewModel.kt @@ -127,25 +127,27 @@ class RoomUploadsViewModel @AssistedInject constructor( private fun handleShare(action: RoomUploadsAction.Share) { viewModelScope.launch { - try { + val event = try { val file = session.fileService().downloadFile( messageContent = action.uploadEvent.contentWithAttachmentContent) - _viewEvents.post(RoomUploadsViewEvents.FileReadyForSharing(file)) + RoomUploadsViewEvents.FileReadyForSharing(file) } catch (failure: Throwable) { - _viewEvents.post(RoomUploadsViewEvents.Failure(failure)) + RoomUploadsViewEvents.Failure(failure) } + _viewEvents.post(event) } } private fun handleDownload(action: RoomUploadsAction.Download) { viewModelScope.launch { - try { + val event = try { val file = session.fileService().downloadFile( messageContent = action.uploadEvent.contentWithAttachmentContent) - _viewEvents.post(RoomUploadsViewEvents.FileReadyForSaving(file, action.uploadEvent.contentWithAttachmentContent.body)) + RoomUploadsViewEvents.FileReadyForSaving(file, action.uploadEvent.contentWithAttachmentContent.body) } catch (failure: Throwable) { - _viewEvents.post(RoomUploadsViewEvents.Failure(failure)) + RoomUploadsViewEvents.Failure(failure) } + _viewEvents.post(event) } } }