simplify call logic

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-07-18 18:50:00 +02:00
parent 480122d648
commit 96910c02a1
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B

View File

@ -124,10 +124,11 @@ class UserManager internal constructor(private val userRepository: UsersReposito
}
fun updateUser(user: User): Single<Int> {
return if (user.id != null) {
Single.just(userRepository.updateUser(user))
} else {
Single.just(userRepository.insertUser(user).toInt())
return Single.fromCallable {
when (user.id) {
null -> userRepository.insertUser(user).toInt()
else -> userRepository.updateUser(user)
}
}
}