Browse Source

fix: 图片出现在头部的bug

master
xsx 2 years ago
parent
commit
943efae7a0
  1. 5
      im-ui/src/store/chatStore.js
  2. 3
      im-uniapp/store/chatStore.js

5
im-ui/src/store/chatStore.js

@ -176,9 +176,8 @@ export default {
}
// 根据id顺序插入,防止消息乱序
let insertPos = chat.messages.length;
if(msgInfo.id>0){
// 防止 图片、文件 在发送方 显示 在顶端 因为还没存库,id=0
if(msgInfo.id && msgInfo.id > 0){
for (let idx in chat.messages) {
if (chat.messages[idx].id && msgInfo.id < chat.messages[idx].id) {
insertPos = idx;
@ -187,8 +186,6 @@ export default {
}
}
}
chat.messages.splice(insertPos, 0, msgInfo);
this.commit("saveToStorage");
},

3
im-uniapp/store/chatStore.js

@ -178,6 +178,8 @@ export default {
}
// 根据id顺序插入,防止消息乱序
let insertPos = chat.messages.length;
// 防止 图片、文件 在发送方 显示 在顶端 因为还没存库,id=0
if(msgInfo.id && msgInfo.id > 0){
for (let idx in chat.messages) {
if (chat.messages[idx].id && msgInfo.id < chat.messages[idx].id) {
insertPos = idx;
@ -185,6 +187,7 @@ export default {
break;
}
}
}
chat.messages.splice(insertPos, 0, msgInfo);
this.commit("saveToStorage");
},

Loading…
Cancel
Save