simplify call chain

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-06-24 09:38:47 +02:00
parent 443110557c
commit 84c1874284
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -45,14 +45,13 @@ class UserManager internal constructor(private val userRepository: UsersReposito
val results = userRepository.getUsersNotScheduledForDeletion()
return results.map { users ->
var result: User? = null
if (users.isNotEmpty()) {
val user = users[0]
user.current = true
userRepository.updateUser(user)
result = user
}
result
users
.firstOrNull()
?.apply {
current = true
}?.also { user ->
userRepository.updateUser(user)
}
}
}