From f36d3cae89e9ccbf4372c3faee1811500bc71888 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:07:34 +0000 Subject: [PATCH] Update dependency org.matrix.rustcomponents:sdk-android to v0.1.96 (#2323) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update dependency org.matrix.rustcomponents:sdk-android to v0.1.96 * Fixes for the SDK upgrade --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jorge Martín --- gradle/libs.versions.toml | 2 +- .../libraries/matrix/api/room/MatrixRoom.kt | 2 -- .../libraries/matrix/impl/RustMatrixClient.kt | 29 ++++++++++++++- .../matrix/impl/room/RustMatrixRoom.kt | 9 ----- .../impl/timeline/AsyncMatrixTimeline.kt | 1 + .../matrix/test/room/FakeMatrixRoom.kt | 4 --- .../libraries/matrix/ui/room/PollHistory.kt | 36 ------------------- 7 files changed, 30 insertions(+), 53 deletions(-) delete mode 100644 libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/room/PollHistory.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ade161ca38..abfb56bfa7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -153,7 +153,7 @@ jsoup = "org.jsoup:jsoup:1.17.2" appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" } molecule-runtime = "app.cash.molecule:molecule-runtime:1.3.2" timber = "com.jakewharton.timber:timber:5.0.1" -matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.95" +matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.96" 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 = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" } diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt index 6d5a552c83..550bb7012a 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt @@ -252,7 +252,5 @@ interface MatrixRoom : Closeable { */ fun getWidgetDriver(widgetSettings: MatrixWidgetSettings): Result - fun pollHistory(): MatrixTimeline - override fun close() = destroy() } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt index 7e749d4322..26bc775e55 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt @@ -76,11 +76,14 @@ import kotlinx.coroutines.withTimeout import org.matrix.rustcomponents.sdk.BackupState import org.matrix.rustcomponents.sdk.Client import org.matrix.rustcomponents.sdk.ClientDelegate +import org.matrix.rustcomponents.sdk.FilterStateEventType +import org.matrix.rustcomponents.sdk.FilterTimelineEventType import org.matrix.rustcomponents.sdk.NotificationProcessSetup import org.matrix.rustcomponents.sdk.PowerLevels import org.matrix.rustcomponents.sdk.Room import org.matrix.rustcomponents.sdk.RoomListItem import org.matrix.rustcomponents.sdk.TaskHandle +import org.matrix.rustcomponents.sdk.TimelineEventTypeFilter import org.matrix.rustcomponents.sdk.use import timber.log.Timber import java.io.File @@ -198,6 +201,25 @@ class RustMatrixClient( ), ) + private val eventFilters = TimelineEventTypeFilter.exclude( + listOf( + FilterStateEventType.ROOM_ALIASES, + FilterStateEventType.ROOM_CANONICAL_ALIAS, + FilterStateEventType.ROOM_GUEST_ACCESS, + FilterStateEventType.ROOM_HISTORY_VISIBILITY, + FilterStateEventType.ROOM_JOIN_RULES, + FilterStateEventType.ROOM_PINNED_EVENTS, + FilterStateEventType.ROOM_POWER_LEVELS, + FilterStateEventType.ROOM_SERVER_ACL, + FilterStateEventType.ROOM_TOMBSTONE, + FilterStateEventType.SPACE_CHILD, + FilterStateEventType.SPACE_PARENT, + FilterStateEventType.POLICY_RULE_ROOM, + FilterStateEventType.POLICY_RULE_SERVER, + FilterStateEventType.POLICY_RULE_USER, + ).map(FilterTimelineEventType::State) + ) + override val roomListService: RoomListService get() = rustRoomListService @@ -248,7 +270,12 @@ class RustMatrixClient( private suspend fun pairOfRoom(roomId: RoomId): Pair? { val cachedRoomListItem = innerRoomListService.roomOrNull(roomId.value) - val fullRoom = cachedRoomListItem?.fullRoom() + val fullRoom = cachedRoomListItem?.let { roomListItem -> + if (!roomListItem.isTimelineInitialized()) { + roomListItem.initTimeline(eventFilters) + } + roomListItem.fullRoom() + } return if (cachedRoomListItem == null || fullRoom == null) { Timber.d("No room cached for $roomId") null diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt index 86bfd2dc12..3fc7d65468 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt @@ -50,7 +50,6 @@ import io.element.android.libraries.matrix.impl.notificationsettings.RustNotific import io.element.android.libraries.matrix.impl.poll.toInner import io.element.android.libraries.matrix.impl.room.location.toInner import io.element.android.libraries.matrix.impl.room.member.RoomMemberListFetcher -import io.element.android.libraries.matrix.impl.timeline.AsyncMatrixTimeline import io.element.android.libraries.matrix.impl.timeline.RustMatrixTimeline import io.element.android.libraries.matrix.impl.util.mxCallbackFlow import io.element.android.libraries.matrix.impl.widget.RustWidgetDriver @@ -545,14 +544,6 @@ class RustMatrixRoom( ) } - override fun pollHistory() = AsyncMatrixTimeline( - coroutineScope = roomCoroutineScope, - dispatcher = roomDispatcher - ) { - val innerTimeline = innerRoom.pollHistory() - createMatrixTimeline(innerTimeline) - } - private fun sendAttachment(files: List, handle: () -> SendAttachmentJoinHandle): Result { return runCatching { MediaUploadHandlerImpl(files, handle()) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/AsyncMatrixTimeline.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/AsyncMatrixTimeline.kt index 0cfb8dfc26..2d6fbd253b 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/AsyncMatrixTimeline.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/AsyncMatrixTimeline.kt @@ -38,6 +38,7 @@ import timber.log.Timber /** * This class is a wrapper around a [MatrixTimeline] that will be created asynchronously. */ +@Suppress("unused") class AsyncMatrixTimeline( coroutineScope: CoroutineScope, dispatcher: CoroutineDispatcher, diff --git a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt index 1b37f689a4..c33a6d43b2 100644 --- a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt +++ b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt @@ -443,10 +443,6 @@ class FakeMatrixRoom( override fun getWidgetDriver(widgetSettings: MatrixWidgetSettings): Result = getWidgetDriverResult - override fun pollHistory(): MatrixTimeline { - return FakeMatrixTimeline() - } - fun givenLeaveRoomError(throwable: Throwable?) { this.leaveRoomError = throwable } diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/room/PollHistory.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/room/PollHistory.kt deleted file mode 100644 index bc695864f7..0000000000 --- a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/room/PollHistory.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.element.android.libraries.matrix.ui.room - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.remember -import io.element.android.libraries.matrix.api.room.MatrixRoom -import io.element.android.libraries.matrix.api.timeline.MatrixTimeline - -@Composable -fun MatrixRoom.rememberPollHistory(): MatrixTimeline { - val pollHistory = remember { - pollHistory() - } - DisposableEffect(pollHistory) { - onDispose { - pollHistory.close() - } - } - return pollHistory -}