mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-28 01:24:03 +03:00
migrate poll view model from requery to room
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
4513866c1d
commit
7ea37b9ee3
1 changed files with 7 additions and 3 deletions
|
@ -27,7 +27,7 @@ import androidx.lifecycle.ViewModel
|
||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.polls.model.Poll
|
import com.nextcloud.talk.polls.model.Poll
|
||||||
import com.nextcloud.talk.polls.repositories.PollRepository
|
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.Observer
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
|
@ -37,7 +37,7 @@ import javax.inject.Inject
|
||||||
class PollMainViewModel @Inject constructor(private val repository: PollRepository) : ViewModel() {
|
class PollMainViewModel @Inject constructor(private val repository: PollRepository) : ViewModel() {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var userUtils: UserUtils
|
lateinit var userManager: UserManager
|
||||||
|
|
||||||
lateinit var user: User
|
lateinit var user: User
|
||||||
lateinit var roomToken: String
|
lateinit var roomToken: String
|
||||||
|
@ -175,7 +175,11 @@ class PollMainViewModel @Inject constructor(private val repository: PollReposito
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isPollCreatedByCurrentUser(poll: Poll): Boolean {
|
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() {
|
fun dismissDialog() {
|
||||||
|
|
Loading…
Reference in a new issue