From 49bbca5b601e6f8d1a34d17e32c3fcf560a3e7c0 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 29 Jun 2023 21:52:57 +0200 Subject: [PATCH] Timeline: disable pre-fetching for now as it leads to more issues than it solves. --- .../messages/impl/timeline/TimelineView.kt | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt index 4d7f2b9978..74bb593f11 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/TimelineView.kt @@ -39,7 +39,6 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.pluralStringResource @@ -62,7 +61,6 @@ import io.element.android.libraries.designsystem.theme.components.Icon import io.element.android.libraries.matrix.api.core.EventId import io.element.android.libraries.matrix.api.core.UserId import kotlinx.collections.immutable.ImmutableList -import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch @Composable @@ -123,8 +121,7 @@ fun TimelineView( TimelineScrollHelper( lazyListState = lazyListState, - timelineItems = state.timelineItems, - onLoadMore = ::onReachedLoadMore + timelineItems = state.timelineItems ) } } @@ -222,7 +219,6 @@ fun TimelineItemRow( internal fun BoxScope.TimelineScrollHelper( lazyListState: LazyListState, timelineItems: ImmutableList, - onLoadMore: () -> Unit = {}, ) { val coroutineScope = rememberCoroutineScope() val firstVisibleItemIndex by remember { derivedStateOf { lazyListState.firstVisibleItemIndex } } @@ -236,24 +232,6 @@ internal fun BoxScope.TimelineScrollHelper( } } - // Handle load more preloading - val loadMore by remember { - derivedStateOf { - val layoutInfo = lazyListState.layoutInfo - val totalItemsNumber = layoutInfo.totalItemsCount - val lastVisibleItemIndex = (layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0) + 1 - lastVisibleItemIndex > (totalItemsNumber - 30) - } - } - - LaunchedEffect(loadMore) { - snapshotFlow { loadMore } - .distinctUntilChanged() - .collect { - onLoadMore() - } - } - // Jump to bottom button if (firstVisibleItemIndex > 2) { FloatingActionButton(