mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-03 03:18:12 +00:00
perf: 优化消息更新机制
This commit is contained in:
parent
1ce96ddae6
commit
3fa0b472d2
17
resources/assets/js/store/actions.js
vendored
17
resources/assets/js/store/actions.js
vendored
@ -2735,12 +2735,23 @@ export default {
|
|||||||
dispatch("saveDialogMsg", msg)
|
dispatch("saveDialogMsg", msg)
|
||||||
});
|
});
|
||||||
} else if ($A.isJson(data)) {
|
} else if ($A.isJson(data)) {
|
||||||
|
let delay = false
|
||||||
|
if (typeof data.__delay__ !== "undefined") {
|
||||||
|
delete data.__delay__
|
||||||
|
delay = true
|
||||||
|
}
|
||||||
const index = state.dialogMsgs.findIndex(({id}) => id == data.id);
|
const index = state.dialogMsgs.findIndex(({id}) => id == data.id);
|
||||||
data = Object.assign({}, state.dialogMsgs[index], data)
|
data = Object.assign({}, state.dialogMsgs[index], data)
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.dialogMsgs.splice(index, 1, data);
|
state.dialogMsgs.splice(index, 1, data);
|
||||||
} else {
|
} else {
|
||||||
state.dialogMsgs.push(data);
|
if (delay) {
|
||||||
|
setTimeout(_ => {
|
||||||
|
state.dialogMsgs.push(data);
|
||||||
|
}, 100)
|
||||||
|
} else {
|
||||||
|
state.dialogMsgs.push(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
|
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
|
||||||
//
|
//
|
||||||
@ -3275,7 +3286,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 更新消息列表
|
// 更新消息列表
|
||||||
dispatch("saveDialogMsg", data)
|
dispatch("saveDialogMsg", Object.assign(data, {__delay__: true}))
|
||||||
// 更新最后消息
|
// 更新最后消息
|
||||||
dispatch("updateDialogLastMsg", data);
|
dispatch("updateDialogLastMsg", data);
|
||||||
break;
|
break;
|
||||||
@ -3283,7 +3294,7 @@ export default {
|
|||||||
case 'readed':
|
case 'readed':
|
||||||
const updateMsg = (data, count) => {
|
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", Object.assign(data, {__delay__: true}))
|
||||||
// 更新待办
|
// 更新待办
|
||||||
if (typeof data.todo !== "undefined") {
|
if (typeof data.todo !== "undefined") {
|
||||||
dispatch("getDialogTodo", dialog_id)
|
dispatch("getDialogTodo", dialog_id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user