Fix thread list not loading older threads (#7034)
* Fix thread list pagination
This commit is contained in:
+2
-1
@@ -101,9 +101,10 @@ class ThreadsListPresenter(
|
||||
coroutineScope.launch {
|
||||
Timber.d("Paginating thread list: $paginationStatus")
|
||||
threadsListService.paginate()
|
||||
.onFailure { Timber.w(it, "Failed to paginate thread list") }
|
||||
}
|
||||
} else {
|
||||
Timber.d("Not paginating since there is nothing else to load, current status: $paginationStatus")
|
||||
Timber.d("Not paginating, current status: $paginationStatus")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -162,14 +162,14 @@ private fun ScrollHelper(
|
||||
val lastVisibleItemIndex by remember {
|
||||
derivedStateOf { listState.firstVisibleItemIndex + listState.layoutInfo.visibleItemsInfo.size - 1 }
|
||||
}
|
||||
val needsPagination by remember {
|
||||
val shouldPaginate by remember {
|
||||
derivedStateOf {
|
||||
val canLoadNewItems = listState.isScrollInProgress || listState.firstVisibleItemScrollOffset == 0
|
||||
canLoadNewItems && lastVisibleItemIndex == listState.layoutInfo.totalItemsCount - 1
|
||||
val canLoadNewItems = listState.isScrollInProgress || listState.layoutInfo.totalItemsCount == 0
|
||||
canLoadNewItems && lastVisibleItemIndex >= listState.layoutInfo.totalItemsCount - 1
|
||||
}
|
||||
}
|
||||
LaunchedEffect(needsPagination, lastVisibleItemIndex) {
|
||||
if (needsPagination) {
|
||||
LaunchedEffect(shouldPaginate, lastVisibleItemIndex) {
|
||||
if (shouldPaginate) {
|
||||
updatedOnPaginate()
|
||||
delay(400L)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user