perf: 优化消息对话排序
This commit is contained in:
parent
004bf36dc1
commit
493cf7d46a
@ -345,7 +345,7 @@ export default {
|
|||||||
|
|
||||||
msgAllUnread() {
|
msgAllUnread() {
|
||||||
let num = 0;
|
let num = 0;
|
||||||
this.cacheDialogs.map(({unread}) => {
|
this.cacheDialogs.some(({unread}) => {
|
||||||
if (unread) {
|
if (unread) {
|
||||||
num += unread;
|
num += unread;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,6 @@ export default {
|
|||||||
sendSuccess(data) {
|
sendSuccess(data) {
|
||||||
this.$store.dispatch("saveDialogMsg", data);
|
this.$store.dispatch("saveDialogMsg", data);
|
||||||
this.$store.dispatch("increaseTaskMsgNum", this.dialogId);
|
this.$store.dispatch("increaseTaskMsgNum", this.dialogId);
|
||||||
this.$store.dispatch("moveDialogTop", this.dialogId);
|
|
||||||
this.$store.dispatch("updateDialogLastMsg", data);
|
this.$store.dispatch("updateDialogLastMsg", data);
|
||||||
this.onActive();
|
this.onActive();
|
||||||
},
|
},
|
||||||
|
@ -124,7 +124,14 @@ export default {
|
|||||||
dialogList() {
|
dialogList() {
|
||||||
const {dialogActive, dialogKey} = this;
|
const {dialogActive, dialogKey} = this;
|
||||||
if (dialogActive == '' && dialogKey == '') {
|
if (dialogActive == '' && dialogKey == '') {
|
||||||
return this.cacheDialogs.filter(({name}) => name !== undefined);
|
return this.cacheDialogs.filter(({name, last_at}) => {
|
||||||
|
if (name === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return last_at;
|
||||||
|
}).sort((a, b) => {
|
||||||
|
return $A.Date(b.last_at) - $A.Date(a.last_at);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return this.cacheDialogs.filter(({name, type, group_type, last_msg, last_at}) => {
|
return this.cacheDialogs.filter(({name, type, group_type, last_msg, last_at}) => {
|
||||||
if (name === undefined) {
|
if (name === undefined) {
|
||||||
@ -159,14 +166,14 @@ export default {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}).sort((a, b) => {
|
}).sort((a, b) => {
|
||||||
return $A.Date(a.last_at) - $A.Date(b.last_at);
|
return $A.Date(b.last_at) - $A.Date(a.last_at);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
msgUnread() {
|
msgUnread() {
|
||||||
return function (type) {
|
return function (type) {
|
||||||
let num = 0;
|
let num = 0;
|
||||||
this.cacheDialogs.map((dialog) => {
|
this.cacheDialogs.some((dialog) => {
|
||||||
if (dialog.unread) {
|
if (dialog.unread) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'project':
|
case 'project':
|
||||||
@ -231,10 +238,10 @@ export default {
|
|||||||
const dialog = this.dialogList.find(({unread}) => unread > 0)
|
const dialog = this.dialogList.find(({unread}) => unread > 0)
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
try {
|
try {
|
||||||
this.$refs[`dialog_${dialog.id}`][0].scrollIntoView({behavior: "smooth"});
|
this.$refs[`dialog_${dialog.id}`][0].scrollIntoView();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
scrollIntoView(this.$refs[`dialog_${dialog.id}`][0], {
|
scrollIntoView(this.$refs[`dialog_${dialog.id}`][0], {
|
||||||
behavior: 'smooth',
|
behavior: 'instant',
|
||||||
inline: 'end',
|
inline: 'end',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
18
resources/assets/js/store/actions.js
vendored
18
resources/assets/js/store/actions.js
vendored
@ -1749,22 +1749,6 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 将会话移动到首位
|
|
||||||
* @param state
|
|
||||||
* @param dialog_id
|
|
||||||
*/
|
|
||||||
moveDialogTop({state}, dialog_id) {
|
|
||||||
$A.execMainDispatch("moveDialogTop", dialog_id)
|
|
||||||
//
|
|
||||||
const index = state.cacheDialogs.findIndex(({id}) => id == dialog_id);
|
|
||||||
if (index > -1) {
|
|
||||||
const tmp = $A.cloneJSON(state.cacheDialogs[index]);
|
|
||||||
state.cacheDialogs.splice(index, 1);
|
|
||||||
state.cacheDialogs.unshift(tmp);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 忘记对话数据
|
* 忘记对话数据
|
||||||
* @param state
|
* @param state
|
||||||
@ -2026,8 +2010,6 @@ export default {
|
|||||||
if (dialog) {
|
if (dialog) {
|
||||||
// 新增未读数
|
// 新增未读数
|
||||||
dialog.unread++;
|
dialog.unread++;
|
||||||
// 移动到首位
|
|
||||||
dispatch("moveDialogTop", dialog_id);
|
|
||||||
}
|
}
|
||||||
Store.set('dialogMsgPush', data);
|
Store.set('dialogMsgPush', data);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user