mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
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 {
|
coroutineScope.launch {
|
||||||
Timber.d("Paginating thread list: $paginationStatus")
|
Timber.d("Paginating thread list: $paginationStatus")
|
||||||
threadsListService.paginate()
|
threadsListService.paginate()
|
||||||
|
.onFailure { Timber.w(it, "Failed to paginate thread list") }
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
val lastVisibleItemIndex by remember {
|
||||||
derivedStateOf { listState.firstVisibleItemIndex + listState.layoutInfo.visibleItemsInfo.size - 1 }
|
derivedStateOf { listState.firstVisibleItemIndex + listState.layoutInfo.visibleItemsInfo.size - 1 }
|
||||||
}
|
}
|
||||||
val needsPagination by remember {
|
val shouldPaginate by remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
val canLoadNewItems = listState.isScrollInProgress || listState.firstVisibleItemScrollOffset == 0
|
val canLoadNewItems = listState.isScrollInProgress || listState.layoutInfo.totalItemsCount == 0
|
||||||
canLoadNewItems && lastVisibleItemIndex == listState.layoutInfo.totalItemsCount - 1
|
canLoadNewItems && lastVisibleItemIndex >= listState.layoutInfo.totalItemsCount - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LaunchedEffect(needsPagination, lastVisibleItemIndex) {
|
LaunchedEffect(shouldPaginate, lastVisibleItemIndex) {
|
||||||
if (needsPagination) {
|
if (shouldPaginate) {
|
||||||
updatedOnPaginate()
|
updatedOnPaginate()
|
||||||
delay(400L)
|
delay(400L)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user