Sfoglia il codice sorgente

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

xsx 5 mesi fa
parent
commit
45c5648266
2 ha cambiato i file con 11 aggiunte e 17 eliminazioni
  1. 6 11
      im-uniapp/store/chatStore.js
  2. 5 6
      im-web/src/store/chatStore.js

+ 6 - 11
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) {

+ 5 - 6
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) {