Upgrade rust sdk to .55 (#1365)

Accomodates breaking changes.
This commit is contained in:
Marco Romano
2023-09-19 13:33:03 +02:00
committed by GitHub
parent d291622eea
commit 52bbede960
4 changed files with 18 additions and 11 deletions

View File

@@ -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" }

View File

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

View File

@@ -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> =
}
}
tryOrNull {
syncIndicator(listener)
syncIndicator(
SYNC_INDICATOR_DELAY_BEFORE_SHOWING,
SYNC_INDICATOR_DELAY_BEFORE_HIDING,
listener,
)
}
}.buffer(Channel.UNLIMITED)

View File

@@ -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(
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(
}
.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)