Join room : change state and view

This commit is contained in:
ganfra 2024-04-12 14:09:57 +02:00
parent ab8c31541b
commit a2329fc7df
11 changed files with 228 additions and 165 deletions

View file

@ -16,6 +16,7 @@
package io.element.android.libraries.matrix.impl.util
import io.element.android.libraries.core.data.tryOrNull
import kotlinx.coroutines.channels.ProducerScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.callbackFlow
@ -23,7 +24,9 @@ import org.matrix.rustcomponents.sdk.TaskHandle
internal fun <T> mxCallbackFlow(block: suspend ProducerScope<T>.() -> TaskHandle?) =
callbackFlow {
val taskHandle: TaskHandle? = block(this)
val taskHandle: TaskHandle? = tryOrNull {
block(this)
}
awaitClose {
taskHandle?.cancelAndDestroy()
}