|
@@ -124,8 +124,7 @@ const getChatList = async (type = 'init') => {
|
|
|
})
|
|
|
pageNum.value = page;
|
|
|
await handleResponse(res);
|
|
|
- currConversationChatList.value = handleChatList(res.data?.data)
|
|
|
- console.log(currConversationChatList.value, 'currConversationChatList')
|
|
|
+ currConversationChatList.value = chatsStore.handleMessageList(res.data?.data)
|
|
|
if (type === 'init') await scrollToBottom()
|
|
|
} catch (e) {
|
|
|
console.error(e)
|
|
@@ -133,9 +132,6 @@ const getChatList = async (type = 'init') => {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-const handleChatList = (list = []) => {
|
|
|
- return (list ?? []).filter(o => isValidJson(o.messageContent)).map(o => JSON.parse(o.messageContent));
|
|
|
-}
|
|
|
|
|
|
// 发送文本消息
|
|
|
const sendTextMessage = async (text) => {
|
|
@@ -271,11 +267,17 @@ onMounted(() => {
|
|
|
initGroupId()
|
|
|
|
|
|
XYWebSocket.SocketEventsBus.on(XYWebSocket.SocketEvents.chatEvent, async (chat) => {
|
|
|
+ console.log('订阅群聊消息', chat)
|
|
|
const isCurrGroupId = chat.groupId && chat.groupId === groupId.value;
|
|
|
const isOtherUserMessage = chat.sendUserId && chatsStore.isRealMessage(chat.sendUserId);
|
|
|
- if (isCurrGroupId && isOtherUserMessage) {
|
|
|
- currConversationChatList.value.push(chat)
|
|
|
- await scrollToBottom()
|
|
|
+ if(isCurrGroupId) {
|
|
|
+ if (isOtherUserMessage) {
|
|
|
+ currConversationChatList.value.push(chat)
|
|
|
+ await scrollToBottom()
|
|
|
+ }
|
|
|
+ if(!isOtherUserMessage) {
|
|
|
+ await getChatList('init')
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
})
|