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> { fun updateUser(user: User): Single<Int> {
return if (user.id != null) { return Single.fromCallable {
Single.just(userRepository.updateUser(user)) when (user.id) {
} else { null -> userRepository.insertUser(user).toInt()
Single.just(userRepository.insertUser(user).toInt()) else -> userRepository.updateUser(user)
}
} }
} }