diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/files/operations/FileOperationsViewModel.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/files/operations/FileOperationsViewModel.kt index c9efcb62ac3..4477989bfb7 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/files/operations/FileOperationsViewModel.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/files/operations/FileOperationsViewModel.kt @@ -119,7 +119,8 @@ class FileOperationsViewModel( liveData = _removeFileLiveData, useCase = removeFileUseCase, useCaseParams = RemoveFileUseCase.Params(fileOperation.listOfFilesToRemove, fileOperation.removeOnlyLocalCopy), - postValue = fileOperation.listOfFilesToRemove + postValue = fileOperation.listOfFilesToRemove, + requiresConnection = !fileOperation.removeOnlyLocalCopy, ) } @@ -158,12 +159,13 @@ class FileOperationsViewModel( liveData: MediatorLiveData>>, useCase: BaseUseCaseWithResult, useCaseParams: Params, - postValue: PostResult? = null + postValue: PostResult? = null, + requiresConnection: Boolean = true, ) { viewModelScope.launch(coroutinesDispatcherProvider.io) { liveData.postValue(Event(UIResult.Loading())) - if (!contextProvider.isConnected()) { + if (!contextProvider.isConnected() && requiresConnection) { liveData.postValue(Event(UIResult.Error(error = NoNetworkConnectionException()))) Timber.w("${useCase.javaClass.simpleName} will not be executed due to lack of network connection") return@launch