From d39e758e4ee527c98dedfc66f4d86ae641e5de84 Mon Sep 17 00:00:00 2001 From: Kevinlinpr Date: Thu, 10 Oct 2024 03:23:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=8E=9F=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../main/java/com/aiosman/riderpro/ui/chat/ChatScreen.kt | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3b1708c..13e3093 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ .cxx local.properties /.idea/* +app/release/* diff --git a/app/src/main/java/com/aiosman/riderpro/ui/chat/ChatScreen.kt b/app/src/main/java/com/aiosman/riderpro/ui/chat/ChatScreen.kt index 918447e..d8be418 100644 --- a/app/src/main/java/com/aiosman/riderpro/ui/chat/ChatScreen.kt +++ b/app/src/main/java/com/aiosman/riderpro/ui/chat/ChatScreen.kt @@ -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 } } }