恢复原滚动逻辑
This commit is contained in:
@@ -109,13 +109,11 @@ fun ChatScreen(userId: String) {
|
||||
}
|
||||
// 监听滚动状态,触发加载更多
|
||||
LaunchedEffect(listState) {
|
||||
snapshotFlow { listState.layoutInfo.visibleItemsInfo.firstOrNull()?.index }
|
||||
snapshotFlow { listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index }
|
||||
.collect { index ->
|
||||
if (index != null && index < 10 && !isLoadingMore && viewModel.hasMore) { // 调整阈值为 10
|
||||
isLoadingMore = true
|
||||
if (index == listState.layoutInfo.totalItemsCount - 1) {
|
||||
coroutineScope.launch {
|
||||
viewModel.onLoadMore(context)
|
||||
isLoadingMore = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user