Message queuing : expose sending queue status on matrix client.
This commit is contained in:
@@ -115,4 +115,10 @@ interface MatrixClient : Closeable {
|
||||
* connectivity is back on the device.
|
||||
*/
|
||||
suspend fun enableSendingQueue(enable: Boolean)
|
||||
|
||||
/**
|
||||
* Returns the current status of the sending queue as a [StateFlow].
|
||||
* If true, the sending queue is enabled.
|
||||
*/
|
||||
fun sendingQueueStatus(): StateFlow<Boolean>
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ import org.matrix.rustcomponents.sdk.ClientDelegate
|
||||
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.TaskHandle
|
||||
import org.matrix.rustcomponents.sdk.use
|
||||
import timber.log.Timber
|
||||
@@ -551,10 +552,20 @@ class RustMatrixClient(
|
||||
}.distinctUntilChanged()
|
||||
}
|
||||
|
||||
override suspend fun enableSendingQueue(enable: Boolean) = withContext(sessionDispatcher){
|
||||
override suspend fun enableSendingQueue(enable: Boolean) = withContext(sessionDispatcher) {
|
||||
client.enableSendingQueue(enable)
|
||||
}
|
||||
|
||||
override fun sendingQueueStatus(): StateFlow<Boolean> = mxCallbackFlow {
|
||||
client.subscribeToSendingQueueStatus(object : SendingQueueStatusListener {
|
||||
override fun onValue(newValue: Boolean) {
|
||||
channel.trySend(newValue)
|
||||
}
|
||||
})
|
||||
}
|
||||
.buffer(Channel.UNLIMITED)
|
||||
.stateIn(sessionCoroutineScope, started = SharingStarted.Eagerly, initialValue = true)
|
||||
|
||||
private suspend fun File.getCacheSize(
|
||||
includeCryptoDb: Boolean = false,
|
||||
): Long = withContext(sessionDispatcher) {
|
||||
@@ -594,9 +605,6 @@ class RustMatrixClient(
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private val defaultRoomCreationPowerLevels = PowerLevels(
|
||||
|
||||
@@ -305,4 +305,7 @@ class FakeMatrixClient(
|
||||
}
|
||||
|
||||
override suspend fun enableSendingQueue(enable: Boolean) = enableSendingQueueLambda(enable)
|
||||
|
||||
var sendingQueueStatusFlow = MutableStateFlow(true)
|
||||
override fun sendingQueueStatus(): StateFlow<Boolean> = sendingQueueStatusFlow
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user