Skip to content

Commit

Permalink
Use client manager to retrieve the spaces service
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgardep committed Feb 13, 2023
1 parent f51e8e6 commit c0f8e64
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package com.owncloud.android.dependecyinjection

import android.accounts.Account
import com.owncloud.android.MainApp
import com.owncloud.android.domain.files.model.FileListOption
import com.owncloud.android.domain.files.model.OCFile
Expand Down Expand Up @@ -113,7 +114,7 @@ val viewModelModule = module {
viewModel { (ocFile: OCFile) -> ConflictsResolveViewModel(get(), get(), get(), get(), get(), ocFile) }
viewModel { ReceiveExternalFilesViewModel(get(), get()) }
viewModel { AccountsManagementViewModel(get()) }
viewModel { (showPersonalSpace: Boolean) ->
SpacesListViewModel(get(), get(), get(), get(), get(), get(), showPersonalSpace)
viewModel { (account: Account, showPersonalSpace: Boolean) ->
SpacesListViewModel(get(), get(), get(), get(), get(), account, showPersonalSpace)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.owncloud.android.extensions.showErrorInSnackbar
import com.owncloud.android.extensions.toDrawableRes
import com.owncloud.android.extensions.toSubtitleStringRes
import com.owncloud.android.extensions.toTitleStringRes
import com.owncloud.android.presentation.authentication.AccountUtils
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf

Expand All @@ -49,6 +50,7 @@ class SpacesListFragment(

private val spacesListViewModel: SpacesListViewModel by viewModel {
parametersOf(
AccountUtils.getCurrentOwnCloudAccount(context),
showPersonalSpace
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import com.owncloud.android.lib.resources.shares.services.ShareService
import com.owncloud.android.lib.resources.shares.services.ShareeService
import com.owncloud.android.lib.resources.shares.services.implementation.OCShareService
import com.owncloud.android.lib.resources.shares.services.implementation.OCShareeService
import com.owncloud.android.lib.resources.spaces.services.OCSpacesService
import com.owncloud.android.lib.resources.spaces.services.SpacesService
import com.owncloud.android.lib.resources.status.services.CapabilityService
import com.owncloud.android.lib.resources.status.services.implementation.OCCapabilityService
import com.owncloud.android.lib.resources.users.services.UserService
Expand Down Expand Up @@ -140,4 +142,9 @@ class ClientManager(
val ownCloudClient = getClientForAccount(accountName)
return OCShareeService(client = ownCloudClient)
}

fun getSpacesService(accountName: String): SpacesService {
val ownCloudClient = getClientForAccount(accountName)
return OCSpacesService(client = ownCloudClient)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package com.owncloud.android.data.spaces.datasources.implementation

import com.owncloud.android.data.ClientManager
import com.owncloud.android.data.executeRemoteOperation
import com.owncloud.android.data.spaces.datasources.RemoteSpacesDataSource
import com.owncloud.android.domain.spaces.model.OCSpace
Expand All @@ -34,14 +35,13 @@ import com.owncloud.android.domain.spaces.model.SpaceSpecialFolder
import com.owncloud.android.domain.spaces.model.SpaceUser
import com.owncloud.android.lib.resources.spaces.responses.IdentityPermissionResponse
import com.owncloud.android.lib.resources.spaces.responses.SpaceResponse
import com.owncloud.android.lib.resources.spaces.services.SpacesService

class OCRemoteSpacesDataSource(
private val spacesService: SpacesService
private val clientManager: ClientManager,
) : RemoteSpacesDataSource {
override fun refreshSpacesForAccount(accountName: String): List<OCSpace> {
val spacesResponse = executeRemoteOperation {
spacesService.getSpaces()
clientManager.getSpacesService(accountName).getSpaces()
}

return spacesResponse.map { it.toModel(accountName) }
Expand Down

0 comments on commit c0f8e64

Please sign in to comment.