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,19 +83,18 @@ abstract class UsersDao {
|
||||||
abstract fun getUserWithUsernameAndServer(username: String, server: String): Maybe<UserEntity>
|
abstract fun getUserWithUsernameAndServer(username: String, server: String): Maybe<UserEntity>
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
open fun setUserAsActiveWithId(id: Long): Single<Boolean> {
|
@Suppress("Detekt.TooGenericExceptionCaught") // blockingGet() only throws RuntimeExceptions per rx docs
|
||||||
return getUsers()
|
open fun setUserAsActiveWithId(id: Long): Boolean {
|
||||||
.map { users ->
|
return try {
|
||||||
users.forEach { user ->
|
getUsers().blockingGet().forEach { user ->
|
||||||
user.current = user.id == id
|
user.current = user.id == id
|
||||||
updateUser(user)
|
updateUser(user)
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
.onErrorReturn { e ->
|
|
||||||
Log.e(TAG, "Error setting user active", e)
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
true
|
||||||
|
} catch (e: RuntimeException) {
|
||||||
|
Log.e(TAG, "Error setting user active", e)
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
|
|
|
@ -74,7 +74,7 @@ class UsersRepositoryImpl(private val usersDao: UsersDao) : UsersRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setUserAsActiveWithId(id: Long): Single<Boolean> {
|
override fun setUserAsActiveWithId(id: Long): Single<Boolean> {
|
||||||
return usersDao.setUserAsActiveWithId(id)
|
return Single.just(usersDao.setUserAsActiveWithId(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteUserWithId(id: Long) {
|
override fun deleteUserWithId(id: Long) {
|
||||||
|
|
Loading…
Reference in a new issue