红点问题修复
This commit is contained in:
@@ -190,6 +190,13 @@ async function sendMessage() {
|
|||||||
inputText.value = ''
|
inputText.value = ''
|
||||||
await nextTick()
|
await nextTick()
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
|
// 发送消息后标记已读,清除该会话红点
|
||||||
|
const conv = chatList.value.find(c => c.userId === selectedChat.value.userId)
|
||||||
|
if (conv && conv.unread > 0) {
|
||||||
|
goEasyMessageRead({ id: String(selectedChat.value.userId) }).catch(() => {})
|
||||||
|
unreadStore.decrease(conv.unread)
|
||||||
|
conv.unread = 0
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('发送消息失败', e)
|
console.error('发送消息失败', e)
|
||||||
if(e =='Error: id can not be the same as your id'){
|
if(e =='Error: id can not be the same as your id'){
|
||||||
@@ -289,17 +296,16 @@ function onConversationsUpdated(conversations) {
|
|||||||
|
|
||||||
function onMessageReceived(message) {
|
function onMessageReceived(message) {
|
||||||
if (!isGoEasyEnabled()) return
|
if (!isGoEasyEnabled()) return
|
||||||
// 更新会话列表中的未读数
|
// 始终累加会话未读数和更新最后一条消息(全局 unreadStore 由 PkAppaside 统一维护)
|
||||||
const conv = chatList.value.find(c => c.userId === message.senderId)
|
const conv = chatList.value.find(c => c.userId === message.senderId)
|
||||||
if (conv) {
|
if (conv) {
|
||||||
conv.unread = (conv.unread || 0) + 1
|
conv.unread = (conv.unread || 0) + 1
|
||||||
conv.lastMessage = message
|
conv.lastMessage = message
|
||||||
}
|
}
|
||||||
// 如果当前正在查看该会话,添加消息到列表
|
// 如果当前正在查看该会话,追加消息到列表
|
||||||
if (selectedChat.value && selectedChat.value.userId === message.senderId) {
|
if (selectedChat.value && selectedChat.value.userId === message.senderId) {
|
||||||
messagesList.value.push(message)
|
messagesList.value.push(message)
|
||||||
nextTick(() => scrollToBottom())
|
nextTick(() => scrollToBottom())
|
||||||
goEasyMessageRead({ id: message.senderId }).catch(() => {})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user