Browse Source

Upgrade rust sdk to .55 (#1365)

Accomodates breaking changes.
pull/1376/head
Marco Romano 1 year ago committed by GitHub
parent
commit
0d05df0651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      gradle/libs.versions.toml
  2. 8
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt
  3. 9
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListExtensions.kt
  4. 10
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt

2
gradle/libs.versions.toml

@ -150,7 +150,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } @@ -150,7 +150,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "molecule" }
timber = "com.jakewharton.timber:timber:5.0.1"
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.54"
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.55"
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
sqldelight-driver-android = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" }

8
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt

@ -187,7 +187,13 @@ class RustMatrixRoom( @@ -187,7 +187,13 @@ class RustMatrixRoom(
_membersStateFlow.value = MatrixRoomMembersState.Pending(prevRoomMembers = currentMembers)
var rustMembers: List<RoomMember>? = null
try {
rustMembers = innerRoom.members()
rustMembers = buildList {
while (true) {
// Loading the whole iterator as a stop-gap measure.
// We should probably implement some sort of paging in the future.
addAll(innerRoom.members().nextChunk(1000u) ?: break)
}
}
val mappedMembers = rustMembers.parallelMap(RoomMemberMapper::map)
_membersStateFlow.value = MatrixRoomMembersState.Ready(mappedMembers)
Result.success(Unit)

9
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListExtensions.kt

@ -37,6 +37,9 @@ import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicator @@ -37,6 +37,9 @@ import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicator
import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicatorListener
import timber.log.Timber
private const val SYNC_INDICATOR_DELAY_BEFORE_SHOWING = 1000u
private const val SYNC_INDICATOR_DELAY_BEFORE_HIDING = 0u
fun RoomList.loadingStateFlow(): Flow<RoomListLoadingState> =
mxCallbackFlow {
val listener = object : RoomListLoadingStateListener {
@ -93,7 +96,11 @@ fun RoomListService.syncIndicator(): Flow<RoomListServiceSyncIndicator> = @@ -93,7 +96,11 @@ fun RoomListService.syncIndicator(): Flow<RoomListServiceSyncIndicator> =
}
}
tryOrNull {
syncIndicator(listener)
syncIndicator(
SYNC_INDICATOR_DELAY_BEFORE_SHOWING,
SYNC_INDICATOR_DELAY_BEFORE_HIDING,
listener,
)
}
}.buffer(Channel.UNLIMITED)

10
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustMatrixTimeline.kt

@ -27,7 +27,6 @@ import io.element.android.libraries.matrix.impl.timeline.item.event.EventTimelin @@ -27,7 +27,6 @@ import io.element.android.libraries.matrix.impl.timeline.item.event.EventTimelin
import io.element.android.libraries.matrix.impl.timeline.item.event.TimelineEventContentMapper
import io.element.android.libraries.matrix.impl.timeline.item.virtual.VirtualTimelineItemMapper
import io.element.android.libraries.matrix.impl.timeline.postprocessor.TimelineEncryptedHistoryPostProcessor
import io.element.android.libraries.matrix.impl.util.TaskHandleBag
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
@ -103,7 +102,6 @@ class RustMatrixTimeline( @@ -103,7 +102,6 @@ class RustMatrixTimeline(
init {
Timber.d("Initialize timeline for room ${matrixRoom.roomId}")
val taskHandleBag = TaskHandleBag()
roomCoroutineScope.launch(dispatcher) {
innerRoom.timelineDiffFlow { initialList ->
postItems(initialList)
@ -120,17 +118,13 @@ class RustMatrixTimeline( @@ -120,17 +118,13 @@ class RustMatrixTimeline(
}
.launchIn(this)
taskHandleBag += fetchMembers().getOrNull()
}.invokeOnCompletion {
taskHandleBag.dispose()
fetchMembers()
}
}
private suspend fun fetchMembers() = withContext(dispatcher) {
initLatch.await()
runCatching {
innerRoom.fetchMembers()
}
innerRoom.fetchMembers()
}
@OptIn(ExperimentalCoroutinesApi::class)

Loading…
Cancel
Save