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:
parent
99909e9b9f
commit
58ed74607d
3 changed files with 6 additions and 4 deletions
|
|
@ -91,7 +91,7 @@ class TimelinePresenter @Inject constructor(
|
|||
}
|
||||
|
||||
LaunchedEffect(timelineItems.size) {
|
||||
computeHasNewItems(timelineItems, prevMostRecentItemId, hasNewItems)
|
||||
computeHasNewItems(timelineItems, prevMostRecentItemId, hasNewItems)
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue