测试:修复聊天可能查询不到chatinfo

This commit is contained in:
luying
2021-11-04 17:45:40 +08:00
parent 73818dc8ac
commit a01a17db8e

View File

@@ -252,7 +252,8 @@ function createChatRec(sender: boolean, curTime: Date, targetRoleId) {
* @param {Date} curTime
*/
async function updateRecentChats(sender: boolean, roleId: string, targetRoleId: string, curTime: Date) {
const { recentPrivateChats } = await ChatInfoModel.findInfo(roleId);
const chatInfo = await ChatInfoModel.findInfo(roleId);
let recentPrivateChats = chatInfo?.recentPrivateChats||[];
const recIdx = recentPrivateChats.findIndex(chat => { return chat.targetRoleId === targetRoleId });
if (recIdx === -1) {
recentPrivateChats.push(createChatRec(sender, curTime, targetRoleId));