Skip to content

Commit

Permalink
Provide only one callback for error (simplify)
Browse files Browse the repository at this point in the history
  • Loading branch information
e-marchand committed Jan 29, 2024
1 parent ae0f6a2 commit 556115b
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class ActionViewModel(apiService: ApiService) : BaseViewModel() {
imagesToUpload: Map<String, Result<RequestBody>>,
onImageUploaded: (parameterName: String, receivedId: String) -> Unit,
onImageFailed: (parameterName: String, throwable: Throwable) -> Unit,
onError: () -> Unit,
onAllUploadFinished: () -> Unit
) {
actionRepository.uploadImage(
Expand All @@ -87,11 +86,8 @@ class ActionViewModel(apiService: ApiService) : BaseViewModel() {
}
}
} else {
error?.let {
onImageFailed(parameterName, it)
}
onImageFailed(parameterName, error ?: UnknownError("Failed to upload image without any known error"))
treatFailure(response, error, "ActionViewModel", ToastMessage.Type.ERROR)
onError()
}
}
) {
Expand Down

0 comments on commit 556115b

Please sign in to comment.