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