Browse Source

修复会话抖动的bug

master
xie.bx 3 years ago
parent
commit
79e29b41ed
  1. 11
      im-ui/src/store/chatStore.js

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

@ -11,6 +11,7 @@ export default {
}, },
openChat(state, chatInfo) { openChat(state, chatInfo) {
let chat = null; let chat = null;
let activeChat = state.activeIndex>=0?state.chats[state.activeIndex]:null;
for (let i in state.chats) { for (let i in state.chats) {
if (state.chats[i].type == chatInfo.type && if (state.chats[i].type == chatInfo.type &&
state.chats[i].targetId === chatInfo.targetId) { state.chats[i].targetId === chatInfo.targetId) {
@ -35,7 +36,15 @@ export default {
}; };
state.chats.unshift(chat); state.chats.unshift(chat);
} }
// 选中会话保持不变
if(activeChat){
state.chats.forEach((chat,idx)=>{
if(activeChat.type == chat.type
&& activeChat.targetId == chat.targetId){
state.activeIndex = idx;
}
})
}
}, },
activeChat(state, idx) { activeChat(state, idx) {
state.activeIndex = idx; state.activeIndex = idx;

Loading…
Cancel
Save