mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
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:
+6
-10
@@ -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? {
|
||||
|
||||
+1
-4
@@ -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)
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user