diff --git a/im-uniapp/pages/chat/chat-box.vue b/im-uniapp/pages/chat/chat-box.vue index 958fa3f..926d58b 100644 --- a/im-uniapp/pages/chat/chat-box.vue +++ b/im-uniapp/pages/chat/chat-box.vue @@ -309,9 +309,11 @@ export default { this.isReceipt = false; // 填充对方id this.fillTargetId(msgInfo, this.chat.targetId); + // 防止发送期间用户切换会话导致串扰 + const chat = this.chat; this.sendMessageRequest(msgInfo).then((m) => { m.selfSend = true; - this.chatStore.insertMessage(m, this.chat); + this.chatStore.insertMessage(m, chat); // 会话置顶 this.moveChatToTop(); }).finally(() => { diff --git a/im-web/src/components/chat/ChatBox.vue b/im-web/src/components/chat/ChatBox.vue index 67a5f8c..bcf1add 100644 --- a/im-web/src/components/chat/ChatBox.vue +++ b/im-web/src/components/chat/ChatBox.vue @@ -456,13 +456,12 @@ export default { msgInfo.receipt = this.isReceipt; } this.lockMessage = true; + const chat = this.chat; this.sendMessageRequest(msgInfo).then((m) => { m.selfSend = true; - this.chatStore.insertMessage(m, this.chat); - // 会话置顶 + this.chatStore.insertMessage(m, chat); this.moveChatToTop(); }).finally(() => { - // 解除锁定 this.scrollToBottom(); this.isReceipt = false; resolve();