From 7ea37b9ee3f3ad68eb6690db55f282dd11c5d900 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sat, 23 Jul 2022 14:14:48 +0200 Subject: [PATCH] migrate poll view model from requery to room Signed-off-by: Andy Scherzinger --- .../talk/polls/viewmodels/PollMainViewModel.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollMainViewModel.kt b/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollMainViewModel.kt index 734b93fdf..da8977e56 100644 --- a/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollMainViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/polls/viewmodels/PollMainViewModel.kt @@ -27,7 +27,7 @@ import androidx.lifecycle.ViewModel import com.nextcloud.talk.data.user.model.User import com.nextcloud.talk.polls.model.Poll import com.nextcloud.talk.polls.repositories.PollRepository -import com.nextcloud.talk.utils.database.user.UserUtils +import com.nextcloud.talk.users.UserManager import io.reactivex.Observer import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable @@ -37,7 +37,7 @@ import javax.inject.Inject class PollMainViewModel @Inject constructor(private val repository: PollRepository) : ViewModel() { @Inject - lateinit var userUtils: UserUtils + lateinit var userManager: UserManager lateinit var user: User lateinit var roomToken: String @@ -175,7 +175,11 @@ class PollMainViewModel @Inject constructor(private val repository: PollReposito } private fun isPollCreatedByCurrentUser(poll: Poll): Boolean { - return userUtils.currentUser?.userId == poll.actorId + if (userManager.currentUser.isEmpty.blockingGet()) { + return false + } else { + return userManager.currentUser.blockingGet().userId == poll.actorId + } } fun dismissDialog() {