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