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))