Commit f9143eac authored by Steven杜宇's avatar Steven杜宇

// AI

parent 77223e6f
......@@ -97,7 +97,7 @@ class YHAIMainChatViewController: YHBaseViewController {
sesseionId in
YHHUD.hide()
self.conversationId = sesseionId
self.getHistoryMessages(false)
self.getHistoryMessages()
}
}
......@@ -111,7 +111,7 @@ class YHAIMainChatViewController: YHBaseViewController {
self.bottomInputView.showKeyBoard(false)
}
func reloadAndScrollToBottom(_ forceScrollToBottom: Bool = false) {
func reloadAndScrollToBottom(_ forceScrollToBottom: Bool = false, _ isNeedAccurate: Bool = false) {
self.tableView.reloadData()
if !forceScrollToBottom && !canTriggerProgrammaticScroll() {
......@@ -119,8 +119,12 @@ class YHAIMainChatViewController: YHBaseViewController {
}
DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
// self.tableView.setContentOffset(.zero, animated: true)
// self.tableView.setContentOffset(CGPointMake(0, 90000), animated: true)
if isNeedAccurate {
self.tableView.setContentOffset(.zero, animated: true)
self.tableView.setContentOffset(CGPointMake(0, 90000), animated: true)
}
// 使用 performBatchUpdates 来确保所有布局更新完成后再滚动
self.tableView.performBatchUpdates(nil) { _ in
......@@ -158,10 +162,8 @@ class YHAIMainChatViewController: YHBaseViewController {
}
// isPull 是否是下拉组件触发
func getHistoryMessages(_ isPull: Bool) {
if !isPull {
YHHUD.show(.progress(message: "加载中..."))
}
func getHistoryMessages() {
YHHUD.show(.progress(message: "加载历史消息中..."))
viewModel.getHistoryChatMessages(botId: robotId, conversationId: conversationId, messageId: "") {
[weak self] success, error in
YHHUD.hide()
......@@ -180,7 +182,7 @@ class YHAIMainChatViewController: YHBaseViewController {
return !uuids.contains($0.messageId)
}
messages.insert(contentsOf: results, at: 0)
self.reloadAndScrollToBottom()
self.reloadAndScrollToBottom(true, true)
}
}
......
......@@ -186,7 +186,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
self.navigationController?.popViewController(animated: true)
}
func reloadAndScrollToBottom(_ forceScrollToBottom: Bool = false) {
func reloadAndScrollToBottom(_ forceScrollToBottom: Bool = false, _ isNeedAccurate: Bool = false) {
self.tableView.reloadData()
if !forceScrollToBottom && !canTriggerProgrammaticScroll() {
......@@ -194,8 +194,12 @@ class YHAIRobotChatViewController: YHBaseViewController {
}
DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
// self.tableView.setContentOffset(.zero, animated: true)
// self.tableView.setContentOffset(CGPointMake(0, 90000), animated: true)
if isNeedAccurate {
self.tableView.setContentOffset(.zero, animated: true)
self.tableView.setContentOffset(CGPointMake(0, 90000), animated: true)
}
// 使用 performBatchUpdates 来确保所有布局更新完成后再滚动
self.tableView.performBatchUpdates(nil) { _ in
......@@ -231,10 +235,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
func getHistoryMessages() {
// YHHUD.show(.progress(message: "加载中..."))
YHHUD.show(.progress(message: "加载历史消息中..."))
viewModel.getHistoryChatMessages(botId: robotId, conversationId: conversationId, messageId: "") {
[weak self] success, error in
// YHHUD.hide()
YHHUD.hide()
guard let self = self else { return }
var results = self.viewModel.historyMessages.map {
......@@ -249,7 +253,7 @@ class YHAIRobotChatViewController: YHBaseViewController {
return !uuids.contains($0.messageId)
}
messages.insert(contentsOf: results, at: 0)
self.tableView.reloadData()
reloadAndScrollToBottom(true, true)
autoResponseLocalTextMessage()
}
......@@ -374,7 +378,6 @@ class YHAIRobotChatViewController: YHBaseViewController {
func isNeedStopResonse() -> Bool {
return self.bottomInputView.status == .loading
}
}
extension YHAIRobotChatViewController: UITableViewDelegate, UITableViewDataSource {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment