Update the SDK bindings to v0.2.39 (#3288)
- Rework `RoomSyncSubscriber` to work with the new `RoomListService.subscribeToRooms` API.
This commit is contained in:
parent
0b8e888540
commit
65718b3e96
4 changed files with 25 additions and 26 deletions
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="1.9.24" />
|
<option name="version" value="1.9.25" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -163,7 +163,7 @@ jsoup = "org.jsoup:jsoup:1.18.1"
|
||||||
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
||||||
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
|
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
|
||||||
timber = "com.jakewharton.timber:timber:5.0.1"
|
timber = "com.jakewharton.timber:timber:5.0.1"
|
||||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.38"
|
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.39"
|
||||||
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
||||||
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
||||||
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||||
|
|
|
||||||
|
|
@ -51,23 +51,15 @@ class RoomSyncSubscriber(
|
||||||
includeHeroes = false,
|
includeHeroes = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun subscribe(roomId: RoomId) = mutex.withLock {
|
suspend fun subscribe(roomId: RoomId) {
|
||||||
withContext(dispatchers.io) {
|
mutex.withLock {
|
||||||
try {
|
withContext(dispatchers.io) {
|
||||||
subscribeToRoom(roomId)
|
|
||||||
} catch (exception: Exception) {
|
|
||||||
Timber.e("Failed to subscribe to room $roomId")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun batchSubscribe(roomIds: List<RoomId>) = mutex.withLock {
|
|
||||||
withContext(dispatchers.io) {
|
|
||||||
for (roomId in roomIds) {
|
|
||||||
try {
|
try {
|
||||||
subscribeToRoom(roomId)
|
if (!isSubscribedTo(roomId)) {
|
||||||
} catch (cancellationException: CancellationException) {
|
Timber.d("Subscribing to room $roomId}")
|
||||||
throw cancellationException
|
roomListService.subscribeToRooms(listOf(roomId.value), settings)
|
||||||
|
}
|
||||||
|
subscribedRoomIds.add(roomId)
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Timber.e("Failed to subscribe to room $roomId")
|
Timber.e("Failed to subscribe to room $roomId")
|
||||||
}
|
}
|
||||||
|
|
@ -75,14 +67,21 @@ class RoomSyncSubscriber(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun subscribeToRoom(roomId: RoomId) {
|
suspend fun batchSubscribe(roomIds: List<RoomId>) = mutex.withLock {
|
||||||
if (!isSubscribedTo(roomId)) {
|
withContext(dispatchers.io) {
|
||||||
Timber.d("Subscribing to room $roomId}")
|
try {
|
||||||
roomListService.room(roomId.value).use { roomListItem ->
|
val roomIdsToSubscribeTo = roomIds.filterNot { isSubscribedTo(it) }
|
||||||
roomListItem.subscribe(settings)
|
if (roomIdsToSubscribeTo.isNotEmpty()) {
|
||||||
|
Timber.d("Subscribing to rooms: $roomIds")
|
||||||
|
roomListService.subscribeToRooms(roomIdsToSubscribeTo.map { it.value }, settings)
|
||||||
|
subscribedRoomIds.addAll(roomIds)
|
||||||
|
}
|
||||||
|
} catch (cancellationException: CancellationException) {
|
||||||
|
throw cancellationException
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
Timber.e(exception, "Failed to subscribe to rooms: $roomIds")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
subscribedRoomIds.add(roomId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isSubscribedTo(roomId: RoomId): Boolean {
|
fun isSubscribedTo(roomId: RoomId): Boolean {
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,8 @@ class RoomSummaryListProcessorTest {
|
||||||
override fun syncIndicator(delayBeforeShowingInMs: UInt, delayBeforeHidingInMs: UInt, listener: RoomListServiceSyncIndicatorListener): TaskHandle {
|
override fun syncIndicator(delayBeforeShowingInMs: UInt, delayBeforeHidingInMs: UInt, listener: RoomListServiceSyncIndicatorListener): TaskHandle {
|
||||||
return TaskHandle(Pointer.NULL)
|
return TaskHandle(Pointer.NULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun subscribeToRooms(roomIds: List<String>, settings: RoomSubscription?) = Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,6 +272,4 @@ class FakeRoomListItem(
|
||||||
override suspend fun latestEvent(): EventTimelineItem? {
|
override suspend fun latestEvent(): EventTimelineItem? {
|
||||||
return latestEvent
|
return latestEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun subscribe(settings: RoomSubscription?) = Unit
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue