From 2ac877fe746de23f2b7c663c05d6268bf9b79098 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sun, 12 Jun 2022 18:36:14 +0200 Subject: [PATCH] [TEST] Improve RR reliability Change-Id: Icfc371829dcbe9103cf4cad40c5371e83db8e23c --- .../android/sdk/internal/database/query/ReadQueries.kt | 7 ++++--- .../sdk/internal/session/room/read/SetReadMarkersTask.kt | 2 +- .../app/features/home/room/detail/TimelineViewModel.kt | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt index c3bedfc4b2..ee770901cb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt @@ -29,7 +29,8 @@ import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity internal fun isEventRead(realmConfiguration: RealmConfiguration, userId: String?, roomId: String?, - eventId: String?): Boolean { + eventId: String?, + ignoreSenderId: Boolean = false): Boolean { if (userId.isNullOrBlank() || roomId.isNullOrBlank() || eventId.isNullOrBlank()) { return false } @@ -42,9 +43,9 @@ internal fun isEventRead(realmConfiguration: RealmConfiguration, when { // The event doesn't exist locally, let's assume it hasn't been read eventToCheck == null -> false - eventToCheck.root?.sender == userId -> true + !ignoreSenderId && eventToCheck.root?.sender == userId -> true // If new event exists and the latest event is from ourselves we can infer the event is read - latestEventIsFromSelf(realm, roomId, userId) -> true + !ignoreSenderId && latestEventIsFromSelf(realm, roomId, userId) -> true eventToCheck.isBeforeLatestReadReceipt(realm, roomId, userId) -> true else -> false } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt index 3fe8a0e80e..11578b08f0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt @@ -92,7 +92,7 @@ internal class DefaultSetReadMarkersTask @Inject constructor( rmDimber.i { "Did not set to $fullyReadEventId" } } if (readReceiptEventId != null && - !isEventRead(monarchy.realmConfiguration, userId, params.roomId, readReceiptEventId)) { + !isEventRead(monarchy.realmConfiguration, userId, params.roomId, readReceiptEventId, ignoreSenderId = true)) { if (LocalEcho.isLocalEchoId(readReceiptEventId)) { Timber.w("Can't set read receipt for local event $readReceiptEventId") } else { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index a6e5d063c6..49b34e62de 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -690,9 +690,9 @@ class TimelineViewModel @AssistedInject constructor( session.coroutineScope.launch(NonCancellable) { rmDimber.i{"set RM and RR to $it"} tryOrNullAnon { room.readService().setReadMarker(it) } - if (loadRoomAtFirstUnread()) { + //if (loadRoomAtFirstUnread()) { tryOrNullAnon { room.readService().setReadReceipt(it) } - } + //} } } mostRecentDisplayedEvent = null