mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 04:59:34 +01:00
use CurrentUserProviderNew and User for polls
use CurrentUserProviderNew and User instead of CurrentUserProvider and UserEntity Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
41d64aa740
commit
4388d66b23
@ -24,13 +24,13 @@
|
||||
package com.nextcloud.talk.dagger.modules
|
||||
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.polls.repositories.PollRepository
|
||||
import com.nextcloud.talk.polls.repositories.PollRepositoryImpl
|
||||
import com.nextcloud.talk.data.source.local.TalkDatabase
|
||||
import com.nextcloud.talk.data.storage.ArbitraryStoragesRepository
|
||||
import com.nextcloud.talk.data.storage.ArbitraryStoragesRepositoryImpl
|
||||
import com.nextcloud.talk.data.user.UsersRepository
|
||||
import com.nextcloud.talk.data.user.UsersRepositoryImpl
|
||||
import com.nextcloud.talk.polls.repositories.PollRepository
|
||||
import com.nextcloud.talk.polls.repositories.PollRepositoryImpl
|
||||
import com.nextcloud.talk.remotefilebrowser.repositories.RemoteFileBrowserItemsRepository
|
||||
import com.nextcloud.talk.remotefilebrowser.repositories.RemoteFileBrowserItemsRepositoryImpl
|
||||
import com.nextcloud.talk.repositories.unifiedsearch.UnifiedSearchRepository
|
||||
@ -38,6 +38,7 @@ import com.nextcloud.talk.repositories.unifiedsearch.UnifiedSearchRepositoryImpl
|
||||
import com.nextcloud.talk.shareditems.repositories.SharedItemsRepository
|
||||
import com.nextcloud.talk.shareditems.repositories.SharedItemsRepositoryImpl
|
||||
import com.nextcloud.talk.utils.database.user.CurrentUserProvider
|
||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import okhttp3.OkHttpClient
|
||||
@ -55,7 +56,7 @@ class RepositoryModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun provideDialogPollRepository(ncApi: NcApi, userProvider: CurrentUserProvider): PollRepository {
|
||||
fun provideDialogPollRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew): PollRepository {
|
||||
return PollRepositoryImpl(ncApi, userProvider)
|
||||
}
|
||||
|
||||
|
@ -23,21 +23,20 @@
|
||||
package com.nextcloud.talk.polls.repositories
|
||||
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.polls.model.Poll
|
||||
import com.nextcloud.talk.polls.model.PollDetails
|
||||
import com.nextcloud.talk.polls.repositories.model.PollDetailsResponse
|
||||
import com.nextcloud.talk.polls.repositories.model.PollResponse
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.database.user.CurrentUserProvider
|
||||
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
||||
import io.reactivex.Observable
|
||||
|
||||
class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvider: CurrentUserProvider) :
|
||||
class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvider: CurrentUserProviderNew) :
|
||||
PollRepository {
|
||||
|
||||
val credentials = ApiUtils.getCredentials(
|
||||
currentUserProvider.currentUser?.username,
|
||||
currentUserProvider.currentUser?.token
|
||||
)
|
||||
val currentUser: User = currentUserProvider.currentUser.blockingGet()
|
||||
val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token)
|
||||
|
||||
override fun createPoll(
|
||||
roomToken: String,
|
||||
@ -50,7 +49,7 @@ class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvid
|
||||
return ncApi.createPoll(
|
||||
credentials,
|
||||
ApiUtils.getUrlForPoll(
|
||||
currentUserProvider.currentUser?.baseUrl,
|
||||
currentUser.baseUrl,
|
||||
roomToken
|
||||
),
|
||||
question,
|
||||
@ -65,29 +64,11 @@ class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvid
|
||||
return ncApi.getPoll(
|
||||
credentials,
|
||||
ApiUtils.getUrlForPoll(
|
||||
currentUserProvider.currentUser?.baseUrl,
|
||||
currentUser.baseUrl,
|
||||
roomToken,
|
||||
pollId
|
||||
),
|
||||
).map { mapToPoll(it.ocs?.data!!) }
|
||||
|
||||
// return Observable.just(
|
||||
// Poll(
|
||||
// id = "aaa",
|
||||
// question = "what if?",
|
||||
// options = listOf("yes", "no", "maybe", "I don't know"),
|
||||
// votes = listOf(0, 0, 0, 0),
|
||||
// actorType = "",
|
||||
// actorId = "",
|
||||
// actorDisplayName = "",
|
||||
// status = 0,
|
||||
// resultMode = 0,
|
||||
// maxVotes = 1,
|
||||
// votedSelf = listOf(0, 0, 0, 0),
|
||||
// numVoters = 0,
|
||||
// details = emptyList()
|
||||
// )
|
||||
// )
|
||||
}
|
||||
|
||||
override fun vote(roomToken: String, pollId: String, options: List<Int>): Observable<Poll>? {
|
||||
@ -95,7 +76,7 @@ class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvid
|
||||
return ncApi.votePoll(
|
||||
credentials,
|
||||
ApiUtils.getUrlForPoll(
|
||||
currentUserProvider.currentUser?.baseUrl,
|
||||
currentUser.baseUrl,
|
||||
roomToken,
|
||||
pollId
|
||||
),
|
||||
@ -108,7 +89,7 @@ class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvid
|
||||
return ncApi.closePoll(
|
||||
credentials,
|
||||
ApiUtils.getUrlForPoll(
|
||||
currentUserProvider.currentUser?.baseUrl,
|
||||
currentUser.baseUrl,
|
||||
roomToken,
|
||||
pollId
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user