Rewrite condition for better clarity

This commit is contained in:
Florian Renaud 2022-11-25 15:35:52 +01:00
parent aa53105f17
commit 620bebc3a3

View file

@ -30,7 +30,6 @@ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.transformWhile
import org.matrix.android.sdk.api.extensions.orTrue
import org.matrix.android.sdk.api.query.QueryStringValue
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.RelationType
@ -122,7 +121,8 @@ class GetMostRecentVoiceBroadcastStateEventUseCase @Inject constructor(
event.hasValue() && event.get().root.isRedacted().not()
}
.flatMapLatest { event ->
if (event.getOrNull()?.root?.isRedacted().orTrue()) {
val isRedactedOrNull = !event.hasValue() || event.get().root.isRedacted()
if (isRedactedOrNull) {
// event is null or redacted, switch to the latest not redacted event
getMostRecentRelatedEventFlow(room, voiceBroadcast)
} else {