mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Message queuing : expose sending queue status on matrix client.
This commit is contained in:
+6
@@ -115,4 +115,10 @@ interface MatrixClient : Closeable {
|
|||||||
* connectivity is back on the device.
|
* connectivity is back on the device.
|
||||||
*/
|
*/
|
||||||
suspend fun enableSendingQueue(enable: Boolean)
|
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>
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-4
@@ -98,6 +98,7 @@ import org.matrix.rustcomponents.sdk.ClientDelegate
|
|||||||
import org.matrix.rustcomponents.sdk.IgnoredUsersListener
|
import org.matrix.rustcomponents.sdk.IgnoredUsersListener
|
||||||
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
|
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
|
||||||
import org.matrix.rustcomponents.sdk.PowerLevels
|
import org.matrix.rustcomponents.sdk.PowerLevels
|
||||||
|
import org.matrix.rustcomponents.sdk.SendingQueueStatusListener
|
||||||
import org.matrix.rustcomponents.sdk.TaskHandle
|
import org.matrix.rustcomponents.sdk.TaskHandle
|
||||||
import org.matrix.rustcomponents.sdk.use
|
import org.matrix.rustcomponents.sdk.use
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@@ -551,10 +552,20 @@ class RustMatrixClient(
|
|||||||
}.distinctUntilChanged()
|
}.distinctUntilChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun enableSendingQueue(enable: Boolean) = withContext(sessionDispatcher){
|
override suspend fun enableSendingQueue(enable: Boolean) = withContext(sessionDispatcher) {
|
||||||
client.enableSendingQueue(enable)
|
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(
|
private suspend fun File.getCacheSize(
|
||||||
includeCryptoDb: Boolean = false,
|
includeCryptoDb: Boolean = false,
|
||||||
): Long = withContext(sessionDispatcher) {
|
): Long = withContext(sessionDispatcher) {
|
||||||
@@ -594,9 +605,6 @@ class RustMatrixClient(
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val defaultRoomCreationPowerLevels = PowerLevels(
|
private val defaultRoomCreationPowerLevels = PowerLevels(
|
||||||
|
|||||||
+3
@@ -305,4 +305,7 @@ class FakeMatrixClient(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun enableSendingQueue(enable: Boolean) = enableSendingQueueLambda(enable)
|
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