mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
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:
committed by
GitHub
parent
99909e9b9f
commit
58ed74607d
+1
-1
@@ -91,7 +91,7 @@ class TimelinePresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(timelineItems.size) {
|
LaunchedEffect(timelineItems.size) {
|
||||||
computeHasNewItems(timelineItems, prevMostRecentItemId, hasNewItems)
|
computeHasNewItems(timelineItems, prevMostRecentItemId, hasNewItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
|
|||||||
+4
-2
@@ -140,6 +140,7 @@ fun TimelineView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
TimelineScrollHelper(
|
TimelineScrollHelper(
|
||||||
|
isTimelineEmpty = state.timelineItems.isEmpty(),
|
||||||
lazyListState = lazyListState,
|
lazyListState = lazyListState,
|
||||||
hasNewItems = state.hasNewItems,
|
hasNewItems = state.hasNewItems,
|
||||||
onScrollFinishedAt = ::onScrollFinishedAt
|
onScrollFinishedAt = ::onScrollFinishedAt
|
||||||
@@ -242,6 +243,7 @@ fun TimelineItemRow(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun BoxScope.TimelineScrollHelper(
|
private fun BoxScope.TimelineScrollHelper(
|
||||||
|
isTimelineEmpty: Boolean,
|
||||||
lazyListState: LazyListState,
|
lazyListState: LazyListState,
|
||||||
hasNewItems: Boolean,
|
hasNewItems: Boolean,
|
||||||
onScrollFinishedAt: (Int) -> Unit,
|
onScrollFinishedAt: (Int) -> Unit,
|
||||||
@@ -259,8 +261,8 @@ private fun BoxScope.TimelineScrollHelper(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(isScrollFinished) {
|
LaunchedEffect(isScrollFinished, isTimelineEmpty) {
|
||||||
if (isScrollFinished) {
|
if (isScrollFinished && !isTimelineEmpty) {
|
||||||
// Notify the parent composable about the first visible item index when scrolling finishes
|
// Notify the parent composable about the first visible item index when scrolling finishes
|
||||||
onScrollFinishedAt(lazyListState.firstVisibleItemIndex)
|
onScrollFinishedAt(lazyListState.firstVisibleItemIndex)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -119,7 +119,7 @@ class TimelinePresenterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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(
|
val timeline = FakeMatrixTimeline(
|
||||||
initialTimelineItems = listOf(
|
initialTimelineItems = listOf(
|
||||||
MatrixTimelineItem.Event(0, anEventTimelineItem())
|
MatrixTimelineItem.Event(0, anEventTimelineItem())
|
||||||
|
|||||||
Reference in New Issue
Block a user