diff --git a/uikit/src/main/java/cn/wildfire/chat/kit/conversation/ConversationFragment.java b/uikit/src/main/java/cn/wildfire/chat/kit/conversation/ConversationFragment.java index 26a85168..a4aeb647 100644 --- a/uikit/src/main/java/cn/wildfire/chat/kit/conversation/ConversationFragment.java +++ b/uikit/src/main/java/cn/wildfire/chat/kit/conversation/ConversationFragment.java @@ -577,6 +577,10 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) { } } else { moveToBottom = false; + int firstVisibleItem = layoutManager.findFirstCompletelyVisibleItemPosition(); + if (firstVisibleItem < 6) { + loadMoreOldMessages(); + } } } }); @@ -1090,7 +1094,6 @@ private void loadMoreOldMessages() { } private void loadMoreOldMessages(boolean scrollToBottom) { - conversationViewModel.loadOldMessages(conversation, targetUser, adapter.getOldestMessageId(), adapter.getOldestMessageUid(), MESSAGE_LOAD_COUNT_PER_TIME, true) .observe(this, uiMessages -> { adapter.addMessagesAtHead(uiMessages);