From 977b6c829bf40e36c694919e5988ce5acecbc210 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Tue, 27 Aug 2024 01:16:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:1.=E5=9B=BE=E7=89=87=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=92=A4=E5=9B=9E=E7=9A=84bug=202.=E4=BC=9A=E8=AF=9D=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=90=8E=E6=97=A0=E6=B3=95=E9=87=8D=E6=96=B0=E6=89=93?= =?UTF-8?q?=E5=BC=80=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/store/chatStore.js | 2 ++ im-web/src/components/chat/ChatBox.vue | 4 ++-- im-web/src/store/chatStore.js | 15 ++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/im-uniapp/store/chatStore.js b/im-uniapp/store/chatStore.js index 6ae6eef..cbd54bd 100644 --- a/im-uniapp/store/chatStore.js +++ b/im-uniapp/store/chatStore.js @@ -335,6 +335,8 @@ export default defineStore('chatStore', { chatKeys: chatKeys } uni.setStorageSync(key, chatsData) + // 清理已删除的会话 + this.chats = this.chats.filter(chat => !chat.delete) }, clear(state) { cacheChats = []; diff --git a/im-web/src/components/chat/ChatBox.vue b/im-web/src/components/chat/ChatBox.vue index 5e619b3..5bb837c 100644 --- a/im-web/src/components/chat/ChatBox.vue +++ b/im-web/src/components/chat/ChatBox.vue @@ -156,9 +156,9 @@ let msgInfo = JSON.parse(JSON.stringify(file.msgInfo)); msgInfo.content = JSON.stringify(data); msgInfo.receipt = this.isReceipt; - this.sendMessageRequest(msgInfo).then((id) => { + this.sendMessageRequest(msgInfo).then((m) => { msgInfo.loadStatus = 'ok'; - msgInfo.id = id; + msgInfo.id = m.id; this.isReceipt = false; this.$store.commit("insertMessage", msgInfo); }) diff --git a/im-web/src/store/chatStore.js b/im-web/src/store/chatStore.js index 551cd3e..ce08089 100644 --- a/im-web/src/store/chatStore.js +++ b/im-web/src/store/chatStore.js @@ -102,22 +102,22 @@ export default { chats[idx].stored = false; this.commit("saveToStorage"); }, - removePrivateChat(state,friendId){ + removePrivateChat(state, friendId) { let chats = this.getters.findChats(); for (let idx in chats) { if (chats[idx].type == 'PRIVATE' && chats[idx].targetId === friendId) { - this.commit("removeChat",idx) + this.commit("removeChat", idx) break; } } }, - removeGroupChat(state,groupId){ + removeGroupChat(state, groupId) { let chats = this.getters.findChats(); for (let idx in chats) { if (chats[idx].type == 'GROUP' && chats[idx].targetId === groupId) { - this.commit("removeChat",idx) + this.commit("removeChat", idx) break; } } @@ -322,6 +322,8 @@ export default { chatKeys: chatKeys } localForage.setItem(key, chatsData) + // 清理已删除的会话 + state.chats = state.chats.filter(chat => !chat.delete) }, clear(state) { cacheChats = [] @@ -337,12 +339,11 @@ export default { localForage.getItem(key).then((chatsData) => { if (!chatsData) { resolve(); - } - else if(chatsData.chats){ + } else if (chatsData.chats) { // 兼容旧版本 context.commit("initChats", chatsData); resolve(); - }else if (chatsData.chatKeys) { + } else if (chatsData.chatKeys) { const promises = []; chatsData.chatKeys.forEach(key => { promises.push(localForage.getItem(key))