恢复原滚动逻辑

This commit is contained in:
2024-10-10 03:23:52 +08:00
parent dfce8e4e90
commit d39e758e4e
2 changed files with 3 additions and 4 deletions

1
.gitignore vendored
View File

@@ -14,3 +14,4 @@
.cxx
local.properties
/.idea/*
app/release/*

View File

@@ -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
}
}
}