Mark room as fully read when user goes back to the room list. (#2687)

* Remove not helping warning.

* Add and improve tests

* Send the `m.fully_read` read marker when the user navigates back to the room list, to mark the room as read.
This commit is contained in:
Benoit Marty 2025-06-04 16:14:29 +02:00 committed by GitHub
parent 390e5cf20d
commit 58d503f661
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 232 additions and 56 deletions

View file

@ -8,7 +8,6 @@
package io.element.android.libraries.push.impl.notifications
import android.content.Intent
import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.matrix.api.MatrixClient
import io.element.android.libraries.matrix.api.core.EventId
import io.element.android.libraries.matrix.api.core.RoomId
@ -224,7 +223,12 @@ class NotificationBroadcastReceiverHandlerTest {
getLambda = getLambda
)
val clearMessagesForRoomLambda = lambdaRecorder<SessionId, RoomId, Unit> { _, _ -> }
val joinedRoom = FakeJoinedRoom()
val markAsReadResult = lambdaRecorder<ReceiptType, Result<Unit>> { Result.success(Unit) }
val joinedRoom = FakeJoinedRoom(
baseRoom = FakeBaseRoom(
markAsReadResult = markAsReadResult,
),
)
val fakeNotificationCleaner = FakeNotificationCleaner(
clearMessagesForRoomLambda = clearMessagesForRoomLambda,
)
@ -243,7 +247,7 @@ class NotificationBroadcastReceiverHandlerTest {
clearMessagesForRoomLambda.assertions()
.isCalledOnce()
.with(value(A_SESSION_ID), value(A_ROOM_ID))
assertThat(joinedRoom.baseRoom.markAsReadCalls).isEqualTo(listOf(expectedReceiptType))
markAsReadResult.assertions().isCalledOnce().with(value(expectedReceiptType))
}
@Test