Sending queue : adjust to match the latest rust api
This commit is contained in:
parent
bdd6a7959a
commit
cd18e5a981
10 changed files with 169 additions and 123 deletions
|
|
@ -114,11 +114,11 @@ interface MatrixClient : Closeable {
|
|||
* so it's required to manually re-enable it as soon as
|
||||
* connectivity is back on the device.
|
||||
*/
|
||||
suspend fun setSendingQueueEnabled(enabled: Boolean)
|
||||
suspend fun setAllSendQueuesEnabled(enabled: Boolean)
|
||||
|
||||
/**
|
||||
* Returns the current status of the sending queue as a [StateFlow].
|
||||
* If true, the sending queue is enabled.
|
||||
* Returns a flow of room IDs that have send queue being disabled.
|
||||
* This flow will emit a new value whenever the send queue is disabled for a room.
|
||||
*/
|
||||
fun sendingQueueStatus(): StateFlow<Boolean>
|
||||
fun sendQueueDisabledFlow(): Flow<RoomId>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,5 +335,7 @@ interface MatrixRoom : Closeable {
|
|||
*/
|
||||
suspend fun sendCallNotificationIfNeeded(): Result<Unit>
|
||||
|
||||
suspend fun setSendQueueEnabled(enabled: Boolean)
|
||||
|
||||
override fun close() = destroy()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,10 +95,11 @@ import kotlinx.coroutines.withTimeout
|
|||
import org.matrix.rustcomponents.sdk.BackupState
|
||||
import org.matrix.rustcomponents.sdk.Client
|
||||
import org.matrix.rustcomponents.sdk.ClientDelegate
|
||||
import org.matrix.rustcomponents.sdk.ClientException
|
||||
import org.matrix.rustcomponents.sdk.IgnoredUsersListener
|
||||
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
|
||||
import org.matrix.rustcomponents.sdk.PowerLevels
|
||||
import org.matrix.rustcomponents.sdk.SendingQueueStatusListener
|
||||
import org.matrix.rustcomponents.sdk.SendQueueRoomErrorListener
|
||||
import org.matrix.rustcomponents.sdk.TaskHandle
|
||||
import org.matrix.rustcomponents.sdk.use
|
||||
import timber.log.Timber
|
||||
|
|
@ -554,20 +555,18 @@ class RustMatrixClient(
|
|||
}.distinctUntilChanged()
|
||||
}
|
||||
|
||||
override suspend fun setSendingQueueEnabled(enabled: Boolean) = withContext(sessionDispatcher) {
|
||||
Timber.i("setSendingQueueEnabled($enabled)")
|
||||
client.enableSendingQueue(enabled)
|
||||
override suspend fun setAllSendQueuesEnabled(enabled: Boolean) = withContext(sessionDispatcher) {
|
||||
Timber.i("setAllSendQueuesEnabled($enabled)")
|
||||
client.enableAllSendQueues(enabled)
|
||||
}
|
||||
|
||||
override fun sendingQueueStatus(): StateFlow<Boolean> = mxCallbackFlow {
|
||||
client.subscribeToSendingQueueStatus(object : SendingQueueStatusListener {
|
||||
override fun onValue(newValue: Boolean) {
|
||||
channel.trySend(newValue)
|
||||
override fun sendQueueDisabledFlow(): Flow<RoomId> = mxCallbackFlow {
|
||||
client.subscribeToSendQueueStatus(object : SendQueueRoomErrorListener {
|
||||
override fun onError(roomId: String, error: ClientException) {
|
||||
trySend(RoomId(roomId))
|
||||
}
|
||||
})
|
||||
}
|
||||
.buffer(Channel.UNLIMITED)
|
||||
.stateIn(sessionCoroutineScope, started = SharingStarted.Eagerly, initialValue = true)
|
||||
}.buffer(Channel.UNLIMITED)
|
||||
|
||||
private suspend fun File.getCacheSize(
|
||||
includeCryptoDb: Boolean = false,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ import org.matrix.rustcomponents.sdk.WidgetCapabilities
|
|||
import org.matrix.rustcomponents.sdk.WidgetCapabilitiesProvider
|
||||
import org.matrix.rustcomponents.sdk.getElementCallRequiredPermissions
|
||||
import org.matrix.rustcomponents.sdk.use
|
||||
import timber.log.Timber
|
||||
import uniffi.matrix_sdk.RoomPowerLevelChanges
|
||||
import java.io.File
|
||||
import org.matrix.rustcomponents.sdk.Room as InnerRoom
|
||||
|
|
@ -594,6 +595,11 @@ class RustMatrixRoom(
|
|||
innerRoom.sendCallNotificationIfNeeded()
|
||||
}
|
||||
|
||||
override suspend fun setSendQueueEnabled(enabled: Boolean) = withContext(roomDispatcher) {
|
||||
Timber.d("setSendQueuesEnabled: $enabled")
|
||||
innerRoom.enableSendQueue(enabled)
|
||||
}
|
||||
|
||||
private fun createTimeline(
|
||||
timeline: InnerTimeline,
|
||||
isLive: Boolean,
|
||||
|
|
|
|||
|
|
@ -54,8 +54,10 @@ import kotlinx.collections.immutable.ImmutableList
|
|||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import java.util.Optional
|
||||
|
|
@ -300,12 +302,12 @@ class FakeMatrixClient(
|
|||
|
||||
override fun getRoomInfoFlow(roomId: RoomId) = getRoomInfoFlowLambda(roomId)
|
||||
|
||||
var setSendingQueueEnabledLambda = lambdaRecorder(ensureNeverCalled = true) { _: Boolean ->
|
||||
var setAllSendQueuesEnabledLambda = lambdaRecorder(ensureNeverCalled = true) { _: Boolean ->
|
||||
// no-op
|
||||
}
|
||||
|
||||
override suspend fun setSendingQueueEnabled(enabled: Boolean) = setSendingQueueEnabledLambda(enabled)
|
||||
override suspend fun setAllSendQueuesEnabled(enabled: Boolean) = setAllSendQueuesEnabledLambda(enabled)
|
||||
|
||||
var sendingQueueStatusFlow = MutableStateFlow(true)
|
||||
override fun sendingQueueStatus(): StateFlow<Boolean> = sendingQueueStatusFlow
|
||||
var sendQueueDisabledFlow = emptyFlow<RoomId>()
|
||||
override fun sendQueueDisabledFlow(): Flow<RoomId> = sendQueueDisabledFlow
|
||||
}
|
||||
|
|
|
|||
|
|
@ -525,6 +525,9 @@ class FakeMatrixRoom(
|
|||
return sendCallNotificationIfNeededResult()
|
||||
}
|
||||
|
||||
var setSendQueueEnabledLambda = { _: Boolean -> }
|
||||
override suspend fun setSendQueueEnabled(enabled: Boolean) = setSendQueueEnabledLambda(enabled)
|
||||
|
||||
override fun getWidgetDriver(widgetSettings: MatrixWidgetSettings): Result<MatrixWidgetDriver> = getWidgetDriverResult
|
||||
|
||||
fun givenRoomMembersState(state: MatrixRoomMembersState) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue