解决发送消息之后,显示延迟的问题

This commit is contained in:
2022-02-07 15:49:38 +08:00
parent f17f264391
commit 1941fe7d99
3 changed files with 23 additions and 16 deletions

View File

@@ -47,9 +47,7 @@
if (!this.disabled) {
RongIMLib.clearTextMessageDraft(this.conversationType, this.targetId)
im.sentText(this.conversationType, this.targetId, this.inputTxt, () => {
setTimeout(() => {
this.$emit('success')
}, 500)
this.$emit('success')
this.inputTxt = ''
})
}

View File

@@ -52,7 +52,7 @@
import sentText from '../components/sentText'
import sentVoice from '../components/sentVoice'
const ChatList = uni.requireNativePlugin('dom')
const ChatList = uni.requireNativePlugin('dom')
export default {
data() {
@@ -81,8 +81,8 @@
this.userInfo = this.$store.getters.userInfo(this.targetId)
// 获取消息列表
this.initMessageList()
this.initMessageList()
uni.setNavigationBarTitle({
title: this.userInfo.name
})
@@ -120,11 +120,18 @@
this.chatType = this.chatType === 1 ? 0 : 1
},
// 获取消息列表
getMessageList() {
im.getMessageList(this.conversationType, this.targetId, (messages) => {
this.messages = messages.reverse()
this.scrollBottom()
})
getMessageList() {
im.getMessageList(
this.conversationType,
this.targetId,
new Date().getTime(),
10,
true,
(messages) => {
console.log(messages);
this.messages = messages.reverse()
this.scrollBottom()
})
},
// 展示好友信息, type 1 是自己, 2 是对方
showUser(targetId, type) {