Small cleanup

This commit is contained in:
Benoit Marty 2021-04-07 13:47:20 +02:00
parent 511a0c22e2
commit 884358b374
1 changed files with 8 additions and 6 deletions

View File

@ -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)
}
}
}