mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 03:01:12 +00:00
perf: 优化临时会话的消息推送
This commit is contained in:
parent
8aa66661ac
commit
d50c8ce691
12
resources/assets/js/store/actions.js
vendored
12
resources/assets/js/store/actions.js
vendored
@ -3792,15 +3792,14 @@ export default {
|
|||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
case 'chat':
|
case 'chat':
|
||||||
|
const isChat = mode === "chat" || $A.isSubElectron;
|
||||||
if (!state.dialogMsgs.find(({id}) => id == data.id)) {
|
if (!state.dialogMsgs.find(({id}) => id == data.id)) {
|
||||||
// 新增任务消息数量
|
// 新增任务消息数量
|
||||||
dispatch("increaseTaskMsgNum", data);
|
dispatch("increaseTaskMsgNum", data);
|
||||||
// 新增回复数量
|
// 新增回复数量
|
||||||
dispatch("increaseMsgReplyNum", data);
|
dispatch("increaseMsgReplyNum", data);
|
||||||
//
|
//
|
||||||
if (mode === "chat" || $A.isSubElectron) {
|
if (!isChat) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.userid !== state.userId) {
|
if (data.userid !== state.userId) {
|
||||||
// 更新对话新增未读数
|
// 更新对话新增未读数
|
||||||
const dialog = state.cacheDialogs.find(({id}) => id == dialog_id);
|
const dialog = state.cacheDialogs.find(({id}) => id == dialog_id);
|
||||||
@ -3822,17 +3821,16 @@ export default {
|
|||||||
Store.set('dialogMsgPush', data);
|
Store.set('dialogMsgPush', data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const saveMsg = (data, count) => {
|
const saveMsg = (data, count) => {
|
||||||
if (count > 5 || state.dialogMsgs.find(({id}) => id == data.id)) {
|
if (count > 5 || state.dialogMsgs.find(({id}) => id == data.id)) {
|
||||||
// 更新消息列表
|
// 更新消息列表
|
||||||
dispatch("saveDialogMsg", data)
|
dispatch("saveDialogMsg", data)
|
||||||
// 更新最后消息
|
// 更新最后消息
|
||||||
dispatch("updateDialogLastMsg", data);
|
!isChat && dispatch("updateDialogLastMsg", data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTimeout(_ => {
|
setTimeout(() => saveMsg(data, count + 1), 50);
|
||||||
saveMsg(data, ++count)
|
|
||||||
}, 20);
|
|
||||||
}
|
}
|
||||||
saveMsg(data, 0);
|
saveMsg(data, 0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user