diff --git a/sdk/init/msgEvent.js b/sdk/init/msgEvent.js index e8322cb1985607b18daf47e0a31ba1682f419a69..3ef2a51a740b11a1ee41d1c9abb6b9de10a1d2a0 100644 --- a/sdk/init/msgEvent.js +++ b/sdk/init/msgEvent.js @@ -61,7 +61,12 @@ msgEvent.onMsg(async res=>{ } = msg // console.log('msgmsgmsgmsgmsg.msg',msg); // 拿到收到消息的会话对象 - let conversation = await $state.conversation.get(conversation_id) + let conversation = $state.conversation.getCached(conversation_id) + let isNewCreateConversation = false + if (!conversation) { + isNewCreateConversation = true + conversation = await $state.conversation.get(conversation_id) + } // 处理其他设备已读某会话的情况 if (msg.type == 'clear-conversation-unreadCount') { @@ -126,7 +131,9 @@ msgEvent.onMsg(async res=>{ isReadableMsg && // 消息不是系统配置了免打扰的 !isMuteMsg && - msg.from_uid != uniCloud.getCurrentUserInfo().uid + msg.from_uid != uniCloud.getCurrentUserInfo().uid && + // 新创建的会话直接读取云端的未读消息数,本地不需要 ++ + !isNewCreateConversation ) { conversation.unread_count++ }