Sfoglia il codice sorgente

修复消息乱序的bug

xie.bx 2 anni fa
parent
commit
7ffe22ec9a
2 ha cambiato i file con 15 aggiunte e 4 eliminazioni
  1. 3 2
      im-ui/src/view/Home.vue
  2. 12 2
      im-uniapp/App.vue

+ 3 - 2
im-ui/src/view/Home.vue

@@ -145,11 +145,12 @@
 					method: 'get'
 				}).then((msgInfos) => {
 					msgInfos.forEach((msgInfo) => {
-						// 标记这条消息是不是自己发的
 						msgInfo.selfSend = msgInfo.sendId == this.$store.state.userStore.userInfo.id;
 						let groupId = msgInfo.groupId;
 						let group = this.$store.state.groupStore.groups.find((g) => g.id == groupId);
-						this.handleGroupMessage(group,msgInfo);
+						if(group){
+							this.insertGroupMessage(group,msgInfo);
+						}
 					})
 					if (msgInfos.length == 100) {
 						// 继续拉取

+ 12 - 2
im-uniapp/App.vue

@@ -69,7 +69,12 @@
 					method: 'get'
 				}).then((msgInfos) => {
 					msgInfos.forEach((msgInfo) => {
-						this.handlePrivateMessage(msgInfo);
+						msgInfo.selfSend = msgInfo.sendId == store.state.userStore.userInfo.id;
+						let friendId = msgInfo.selfSend ? msgInfo.recvId : msgInfo.sendId;
+						let friend = store.state.friendStore.friends.find((f) => f.id == friendId);
+						if(friend){
+							this.insertPrivateMessage(friend,msgInfo);
+						}	
 					})
 					if (msgInfos.length == 100) {
 						// 继续拉取
@@ -86,7 +91,12 @@
 					method: 'get'
 				}).then((msgInfos) => {
 					msgInfos.forEach((msgInfo) => {
-						this.handleGroupMessage(msgInfo);
+						msgInfo.selfSend = msgInfo.sendId == store.state.userStore.userInfo.id;
+						let groupId = msgInfo.groupId;
+						let group = store.state.groupStore.groups.find((g) => g.id == groupId);
+						if(group){
+							this.insertGroupMessage(group,msgInfo);
+						}
 					})
 					if (msgInfos.length == 100) {
 						// 继续拉取