diff --git a/NEKitChat/NEKitChatUI/NEKitChatUI/Classes/Chat/Controller/ChatViewController.swift b/NEKitChat/NEKitChatUI/NEKitChatUI/Classes/Chat/Controller/ChatViewController.swift index 5eb90650..b8b184f7 100644 --- a/NEKitChat/NEKitChatUI/NEKitChatUI/Classes/Chat/Controller/ChatViewController.swift +++ b/NEKitChat/NEKitChatUI/NEKitChatUI/Classes/Chat/Controller/ChatViewController.swift @@ -533,7 +533,9 @@ extension ChatViewController { print("dropDownRemoteRefresh messages count ", messages?.count as Any) weakSelf?.tableView.reloadData() - weakSelf?.tableView.scrollToRow(at: IndexPath(row:count, section: 0), at: .top, animated: false) + if count>0 { + weakSelf?.tableView.scrollToRow(at: IndexPath(row:count, section: 0), at: .top, animated: false) + } weakSelf?.tableView.mj_header?.endRefreshing() } diff --git a/NEKitChat/NEKitChatUI/NEKitChatUI/Classes/Chat/ViewModel/ChatViewModel.swift b/NEKitChat/NEKitChatUI/NEKitChatUI/Classes/Chat/ViewModel/ChatViewModel.swift index b9928e89..1b17b08c 100644 --- a/NEKitChat/NEKitChatUI/NEKitChatUI/Classes/Chat/ViewModel/ChatViewModel.swift +++ b/NEKitChat/NEKitChatUI/NEKitChatUI/Classes/Chat/ViewModel/ChatViewModel.swift @@ -224,6 +224,9 @@ public class ChatViewModel: NSObject, ChatRepoMessageDelegate, NIMChatManagerDel //查询更多本地历史消息 public func getMoreMessageHistory(_ completion: @escaping (Error?,NSInteger, [MessageModel]?) -> Void) { + if messages.count > 0 { + self.oldMsg = messages.last?.message + } weak var weakSelf = self ChatProvider.shared.getMessageHistory(session: self.session, message: self.oldMsg, limit: messagPageNum) { [weak self] error, messages in if let messageArray = messages, messageArray.count > 0 {