Fix sending read receipts when entering a room (#1016)

* Fix sending read receipts when entering a room

* Improve solution for sending a read receipt when opening a room

* Roll back previous solution as it broke unit tests

* Remove dead code
This commit is contained in:
Jorge Martin Espinosa 2023-08-02 13:55:04 +02:00 committed by GitHub
parent 99909e9b9f
commit 58ed74607d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -91,7 +91,7 @@ class TimelinePresenter @Inject constructor(
}
LaunchedEffect(timelineItems.size) {
computeHasNewItems(timelineItems, prevMostRecentItemId, hasNewItems)
computeHasNewItems(timelineItems, prevMostRecentItemId, hasNewItems)
}
LaunchedEffect(Unit) {

View file

@ -140,6 +140,7 @@ fun TimelineView(
}
TimelineScrollHelper(
isTimelineEmpty = state.timelineItems.isEmpty(),
lazyListState = lazyListState,
hasNewItems = state.hasNewItems,
onScrollFinishedAt = ::onScrollFinishedAt
@ -242,6 +243,7 @@ fun TimelineItemRow(
@Composable
private fun BoxScope.TimelineScrollHelper(
isTimelineEmpty: Boolean,
lazyListState: LazyListState,
hasNewItems: Boolean,
onScrollFinishedAt: (Int) -> Unit,
@ -259,8 +261,8 @@ private fun BoxScope.TimelineScrollHelper(
}
}
LaunchedEffect(isScrollFinished) {
if (isScrollFinished) {
LaunchedEffect(isScrollFinished, isTimelineEmpty) {
if (isScrollFinished && !isTimelineEmpty) {
// Notify the parent composable about the first visible item index when scrolling finishes
onScrollFinishedAt(lazyListState.firstVisibleItemIndex)
}

View file

@ -119,7 +119,7 @@ class TimelinePresenterTest {
}
@Test
fun `present - on scroll finished will not send read receipt no event is before the index`() = runTest {
fun `present - on scroll finished will not send read receipt if no event is before the index`() = runTest {
val timeline = FakeMatrixTimeline(
initialTimelineItems = listOf(
MatrixTimelineItem.Event(0, anEventTimelineItem())