Small cleanup

This commit is contained in:
Benoit Marty 2021-04-07 13:47:20 +02:00
parent 511a0c22e2
commit 884358b374

View File

@ -127,25 +127,27 @@ class RoomUploadsViewModel @AssistedInject constructor(
private fun handleShare(action: RoomUploadsAction.Share) { private fun handleShare(action: RoomUploadsAction.Share) {
viewModelScope.launch { viewModelScope.launch {
try { val event = try {
val file = session.fileService().downloadFile( val file = session.fileService().downloadFile(
messageContent = action.uploadEvent.contentWithAttachmentContent) messageContent = action.uploadEvent.contentWithAttachmentContent)
_viewEvents.post(RoomUploadsViewEvents.FileReadyForSharing(file)) RoomUploadsViewEvents.FileReadyForSharing(file)
} catch (failure: Throwable) { } catch (failure: Throwable) {
_viewEvents.post(RoomUploadsViewEvents.Failure(failure)) RoomUploadsViewEvents.Failure(failure)
} }
_viewEvents.post(event)
} }
} }
private fun handleDownload(action: RoomUploadsAction.Download) { private fun handleDownload(action: RoomUploadsAction.Download) {
viewModelScope.launch { viewModelScope.launch {
try { val event = try {
val file = session.fileService().downloadFile( val file = session.fileService().downloadFile(
messageContent = action.uploadEvent.contentWithAttachmentContent) messageContent = action.uploadEvent.contentWithAttachmentContent)
_viewEvents.post(RoomUploadsViewEvents.FileReadyForSaving(file, action.uploadEvent.contentWithAttachmentContent.body)) RoomUploadsViewEvents.FileReadyForSaving(file, action.uploadEvent.contentWithAttachmentContent.body)
} catch (failure: Throwable) { } catch (failure: Throwable) {
_viewEvents.post(RoomUploadsViewEvents.Failure(failure)) RoomUploadsViewEvents.Failure(failure)
} }
_viewEvents.post(event)
} }
} }
} }