Fix detekt issues in develop (#1004)

Co-authored-by: Marco Romano <marcor@element.io>
This commit is contained in:
Jorge Martin Espinosa 2023-07-31 14:01:08 +02:00 committed by GitHub
parent f1d438e701
commit eb80f5bbfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View file

@ -43,15 +43,16 @@ suspend fun <T : Any> ReceiveTurbine<T>.consumeItemsUntilPredicate(
): List<T> {
val items = ArrayList<T>()
tryOrNull {
while (true) {
var foundItemOrFinished = false
while (!foundItemOrFinished) {
when (val event = withTurbineTimeout(timeout) { awaitEvent() }) {
is Event.Item<T> -> {
items.add(event.value)
if (predicate(event.value)) {
break
foundItemOrFinished = true
}
}
else -> break
Event.Complete, is Event.Error -> foundItemOrFinished = true
}
}
}