mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 14:05:40 +03:00
UsersDao: make setUserAsActiveWithId blocking
Room won't accept non-blocking @Transactions, which makes sense Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
0ac26f557b
commit
886a3d0df2
2 changed files with 12 additions and 13 deletions
|
@ -83,16 +83,15 @@ abstract class UsersDao {
|
|||
abstract fun getUserWithUsernameAndServer(username: String, server: String): Maybe<UserEntity>
|
||||
|
||||
@Transaction
|
||||
open fun setUserAsActiveWithId(id: Long): Single<Boolean> {
|
||||
return getUsers()
|
||||
.map { users ->
|
||||
users.forEach { user ->
|
||||
@Suppress("Detekt.TooGenericExceptionCaught") // blockingGet() only throws RuntimeExceptions per rx docs
|
||||
open fun setUserAsActiveWithId(id: Long): Boolean {
|
||||
return try {
|
||||
getUsers().blockingGet().forEach { user ->
|
||||
user.current = user.id == id
|
||||
updateUser(user)
|
||||
}
|
||||
true
|
||||
}
|
||||
.onErrorReturn { e ->
|
||||
} catch (e: RuntimeException) {
|
||||
Log.e(TAG, "Error setting user active", e)
|
||||
false
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class UsersRepositoryImpl(private val usersDao: UsersDao) : UsersRepository {
|
|||
}
|
||||
|
||||
override fun setUserAsActiveWithId(id: Long): Single<Boolean> {
|
||||
return usersDao.setUserAsActiveWithId(id)
|
||||
return Single.just(usersDao.setUserAsActiveWithId(id))
|
||||
}
|
||||
|
||||
override fun deleteUserWithId(id: Long) {
|
||||
|
|
Loading…
Reference in a new issue