mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 22:29:09 +00:00
ensure that getAnyUserAndSetAsActive will set other users to current=false
Before, getAnyUserAndSetAsActive did only set a random first user to current=true without to check if there is any other current user. So it was up to the calling function of getAnyUserAndSetAsActive to check this. I did not identify a scenario where the getAnyUserAndSetAsActive could cause to set multiple users to current, but anyway the new implementation might fix some scenario that i could not reproduce. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
c58df32c87
commit
307ebd384d
@ -8,6 +8,7 @@
|
||||
package com.nextcloud.talk.users
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import com.bluelinelabs.logansquare.LoganSquare
|
||||
import com.nextcloud.talk.data.user.UsersRepository
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
@ -88,12 +89,11 @@ class UserManager internal constructor(private val userRepository: UsersReposito
|
||||
.flatMapMaybe {
|
||||
if (it.isNotEmpty()) {
|
||||
val user = it.first()
|
||||
user.apply {
|
||||
current = true
|
||||
}.also { currentUser ->
|
||||
userRepository.updateUser(currentUser)
|
||||
if (setUserAsActive(user).blockingGet()) {
|
||||
userRepository.getActiveUser()
|
||||
} else {
|
||||
Maybe.empty()
|
||||
}
|
||||
Maybe.just(user)
|
||||
} else {
|
||||
Maybe.empty()
|
||||
}
|
||||
@ -123,6 +123,7 @@ class UserManager internal constructor(private val userRepository: UsersReposito
|
||||
}
|
||||
|
||||
fun setUserAsActive(user: User): Single<Boolean> {
|
||||
Log.d(TAG, "setUserAsActive:" + user.id!!)
|
||||
return userRepository.setUserAsActiveWithId(user.id!!)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user