Skip to content

Commit

Permalink
Allow local removal when device is not connected
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgardep committed Aug 18, 2022
1 parent cfdafcc commit fa9c0f1
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}

Expand Down Expand Up @@ -158,12 +159,13 @@ class FileOperationsViewModel(
liveData: MediatorLiveData<Event<UIResult<PostResult>>>,
useCase: BaseUseCaseWithResult<Type, Params>,
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
Expand Down

0 comments on commit fa9c0f1

Please sign in to comment.