Message queuing : expose sending queue status on matrix client.

This commit is contained in:
ganfra 2024-06-05 18:09:36 +02:00
parent 431f7a4182
commit 41e5a6dd40
3 changed files with 21 additions and 4 deletions

View file

@ -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(