Browse Source

fix: 消息可能一直发送中的bug

master
xsx 6 months ago
parent
commit
45c5648266
  1. 17
      im-uniapp/store/chatStore.js
  2. 11
      im-web/src/store/chatStore.js

17
im-uniapp/store/chatStore.js

@ -519,20 +519,15 @@ export default defineStore('chatStore', {
}
}
}
// 正在发送中的消息可能没有id,只有tmpId
if (msgInfo.tmpId) {
// 正在发送中的临时消息可能没有id,只有tmpId
if (msgInfo.selfSend && msgInfo.tmpId) {
for (let idx = chat.messages.length - 1; idx >= 0; idx--) {
let m = chat.messages[idx];
// 这里只查询临时消息,跳过正常消息
if (m.id) {
continue;
}
// 这里只查询临时消息,跳过有id的正常消息
if (m.id) {
contine;
if (!m.selfSend || !m.tmpId) {
continue;
}
if (m.tmpId && msgInfo.tmpId == m.tmpId) {
return m;
if (msgInfo.tmpId == m.tmpId) {
return idx;
}
// 如果id比要查询的消息小,说明没有这条消息
if (m.tmpId && m.tmpId < msgInfo.tmpId) {

11
im-web/src/store/chatStore.js

@ -547,16 +547,15 @@ export default defineStore('chatStore', {
}
}
}
// 正在发送中的消息可能没有id,只有tmpId
if (msgInfo.tmpId) {
// 正在发送中的临时消息可能没有id,只有tmpId
if (msgInfo.selfSend && msgInfo.tmpId) {
for (let idx = chat.messages.length - 1; idx >= 0; idx--) {
let m = chat.messages[idx];
// 这里只查询临时消息,跳过正常消息
if (m.id) {
if (!m.selfSend || !m.tmpId) {
continue;
}
if (m.tmpId && msgInfo.tmpId == m.tmpId) {
return m;
if (msgInfo.tmpId == m.tmpId) {
return idx;
}
// 如果id比要查询的消息小,说明没有这条消息
if (m.tmpId && m.tmpId < msgInfo.tmpId) {

Loading…
Cancel
Save