mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 19:35:50 +00:00
perf: 优化消息更新太快导致不更新数据的情况
This commit is contained in:
parent
603db9de7f
commit
9ca9de0d7e
33
resources/assets/js/store/actions.js
vendored
33
resources/assets/js/store/actions.js
vendored
@ -3261,27 +3261,22 @@ export default {
|
||||
break;
|
||||
case 'update':
|
||||
case 'readed':
|
||||
// 更新、已读回执
|
||||
if (state.dialogMsgs.find(({id}) => id == data.id)) {
|
||||
dispatch("saveDialogMsg", data)
|
||||
// 更新待办
|
||||
if (typeof data.todo !== "undefined") {
|
||||
dispatch("getDialogTodo", dialog_id)
|
||||
const updateMsg = (data, count) => {
|
||||
if (state.dialogMsgs.find(({id}) => id == data.id)) {
|
||||
dispatch("saveDialogMsg", data)
|
||||
// 更新待办
|
||||
if (typeof data.todo !== "undefined") {
|
||||
dispatch("getDialogTodo", dialog_id)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (count <= 5) {
|
||||
setTimeout(_ => {
|
||||
updateMsg(data, ++count)
|
||||
}, 500);
|
||||
}
|
||||
} else if (mode === 'readed') {
|
||||
// 消息不存在,重试已读标记
|
||||
let readedNum = 0
|
||||
const readedTimer = setInterval(_ => {
|
||||
if (readedNum > 6) {
|
||||
clearInterval(readedTimer)
|
||||
}
|
||||
if (state.dialogMsgs.find(({id}) => id == data.id)) {
|
||||
clearInterval(readedTimer)
|
||||
dispatch("saveDialogMsg", data)
|
||||
}
|
||||
readedNum++
|
||||
}, 500)
|
||||
}
|
||||
updateMsg(data, 0);
|
||||
break;
|
||||
case 'groupAdd':
|
||||
case 'groupJoin':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user