mxCallbackFlow already contains a tryOrNull wrapper around the block, so not need to add an extra one.
Also the block can return a non-null TaskHandle.
This commit is contained in:
parent
77564d7870
commit
1309d04649
3 changed files with 8 additions and 15 deletions
|
|
@ -97,9 +97,7 @@ internal fun RoomListServiceInterface.stateFlow(): Flow<RoomListServiceState> =
|
|||
trySendBlocking(state)
|
||||
}
|
||||
}
|
||||
tryOrNull {
|
||||
state(listener)
|
||||
}
|
||||
state(listener)
|
||||
}.buffer(Channel.UNLIMITED)
|
||||
|
||||
internal fun RoomListServiceInterface.syncIndicator(): Flow<RoomListServiceSyncIndicator> =
|
||||
|
|
@ -109,13 +107,11 @@ internal fun RoomListServiceInterface.syncIndicator(): Flow<RoomListServiceSyncI
|
|||
trySendBlocking(syncIndicator)
|
||||
}
|
||||
}
|
||||
tryOrNull {
|
||||
syncIndicator(
|
||||
SYNC_INDICATOR_DELAY_BEFORE_SHOWING,
|
||||
SYNC_INDICATOR_DELAY_BEFORE_HIDING,
|
||||
listener,
|
||||
)
|
||||
}
|
||||
syncIndicator(
|
||||
SYNC_INDICATOR_DELAY_BEFORE_SHOWING,
|
||||
SYNC_INDICATOR_DELAY_BEFORE_HIDING,
|
||||
listener,
|
||||
)
|
||||
}.buffer(Channel.UNLIMITED)
|
||||
|
||||
internal fun RoomListServiceInterface.roomOrNull(roomId: String): RoomListItem? {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
package io.element.android.libraries.matrix.impl.sync
|
||||
|
||||
import io.element.android.libraries.core.data.tryOrNull
|
||||
import io.element.android.libraries.matrix.impl.util.mxCallbackFlow
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.channels.trySendBlocking
|
||||
|
|
@ -24,7 +23,5 @@ fun SyncServiceInterface.stateFlow(): Flow<SyncServiceState> =
|
|||
trySendBlocking(state)
|
||||
}
|
||||
}
|
||||
tryOrNull {
|
||||
state(listener)
|
||||
}
|
||||
state(listener)
|
||||
}.buffer(Channel.UNLIMITED)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import kotlinx.coroutines.channels.awaitClose
|
|||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import org.matrix.rustcomponents.sdk.TaskHandle
|
||||
|
||||
internal fun <T> mxCallbackFlow(block: suspend ProducerScope<T>.() -> TaskHandle?) =
|
||||
internal fun <T> mxCallbackFlow(block: suspend ProducerScope<T>.() -> TaskHandle) =
|
||||
callbackFlow {
|
||||
val taskHandle: TaskHandle? = tryOrNull {
|
||||
block(this)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue