From 63cfd9463fa0600b750364063ed95452af092bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Tue, 16 Aug 2022 09:41:47 +0200 Subject: [PATCH] Allow local removal when device is not connected --- .../ui/files/operations/FileOperationsViewModel.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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