未读显示bug修复
This commit is contained in:
@@ -306,9 +306,6 @@ export default {
|
|||||||
changeMenu(menu) {
|
changeMenu(menu) {
|
||||||
this.activeMenu = menu;
|
this.activeMenu = menu;
|
||||||
this.currentContact = null;
|
this.currentContact = null;
|
||||||
if (menu === "contacts") {
|
|
||||||
this.getContactList();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
@@ -326,6 +323,7 @@ export default {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.currentUser = response.data;
|
this.currentUser = response.data;
|
||||||
this.getRecentMessageList();
|
this.getRecentMessageList();
|
||||||
|
this.getContactList();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -492,9 +490,11 @@ export default {
|
|||||||
contactName: contactName,
|
contactName: contactName,
|
||||||
content: newMessage.content,
|
content: newMessage.content,
|
||||||
createdAt: newMessage.createdAt,
|
createdAt: newMessage.createdAt,
|
||||||
unreadCount: 1,
|
unreadCount: 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$nextTick();
|
||||||
},
|
},
|
||||||
|
|
||||||
// 监听websocket连接成功事件
|
// 监听websocket连接成功事件
|
||||||
@@ -535,21 +535,20 @@ export default {
|
|||||||
from: "other",
|
from: "other",
|
||||||
time: message.createdAt,
|
time: message.createdAt,
|
||||||
});
|
});
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.scrollToBottom();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// 不是当前联系人,不加入 contactMessages
|
// 不是当前联系人,不加入 contactMessages
|
||||||
// 如果是当前联系人列表中的成员,更新最近聊天列表、未读数量
|
// 如果是当前联系人列表中的成员,更新最近聊天列表、未读数量
|
||||||
const contactIndex = this.contactList.findIndex(
|
const contactIndex = this.contactList.findIndex(
|
||||||
(item) => item.contactName === senderName
|
(item) => item.contactName === senderName
|
||||||
);
|
);
|
||||||
|
console.log("contactIndex="+contactIndex)
|
||||||
if (contactIndex === -1) return;
|
if (contactIndex === -1) return;
|
||||||
|
|
||||||
this.updateRecentChat("receive", senderName, message);
|
this.updateRecentChat("receive", senderName, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.scrollToBottom();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 发送新消息成功之后,需要把新消息显示到聊天框中(由于要拿数据库里的写入时间,所以要等websocket返回成功再刷新)
|
// 发送新消息成功之后,需要把新消息显示到聊天框中(由于要拿数据库里的写入时间,所以要等websocket返回成功再刷新)
|
||||||
} else if (data.type == "sendSuccess") {
|
} else if (data.type == "sendSuccess") {
|
||||||
const message = data.message;
|
const message = data.message;
|
||||||
|
|||||||
Reference in New Issue
Block a user