diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 3fb917c76..aa49d83ef 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -186,3 +186,10 @@ $A.execMainDispatch = (action, data) => { } }; +window.execMainCacheData = {} +$A.execMainCacheJudge = (key) => { + const val = window.execMainCacheData[key] || false + window.execMainCacheData[key] = true + return val +}; + diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 4a9b78116..ec6a62972 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -1345,8 +1345,8 @@ export default { } this.$store.dispatch("saveDialogMsg", data); if (!this.replyActiveUpdate) { - this.$store.dispatch("increaseTaskMsgNum", this.dialogId); - this.$store.dispatch("increaseMsgReplyNum", data.reply_id); + this.$store.dispatch("increaseTaskMsgNum", data); + this.$store.dispatch("increaseMsgReplyNum", data); this.$store.dispatch("updateDialogLastMsg", data); } this.onCancelReply(); diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 0152873f7..f6030ff92 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -1122,13 +1122,17 @@ export default { /** * 增加任务消息数量 * @param state - * @param dialog_id + * @param data {id, dialog_id} */ - increaseTaskMsgNum({state}, dialog_id) { - $A.execMainDispatch("increaseTaskMsgNum", dialog_id) + increaseTaskMsgNum({state}, data) { + $A.execMainDispatch("increaseTaskMsgNum", data) // - if (dialog_id) { - const task = state.cacheTasks.find(task => task.dialog_id === dialog_id); + if ($A.execMainCacheJudge(`increaseTaskMsgNum:${data.id}`)) { + return + } + // + if (data.dialog_id) { + const task = state.cacheTasks.find(({dialog_id}) => dialog_id === data.dialog_id); if (task) task.msg_num++; } }, @@ -1137,13 +1141,17 @@ export default { * 新增回复数量 * @param state * @param dispatch - * @param reply_id + * @param data {id, reply_id} */ - increaseMsgReplyNum({state, dispatch}, reply_id) { - $A.execMainDispatch("increaseMsgReplyNum", reply_id) + increaseMsgReplyNum({state, dispatch}, data) { + $A.execMainDispatch("increaseMsgReplyNum", data) // - if (reply_id > 0) { - const msg = state.dialogMsgs.find(({id}) => id == reply_id) + if ($A.execMainCacheJudge(`increaseMsgReplyNum:${data.id}`)) { + return + } + // + if (data.reply_id > 0) { + const msg = state.dialogMsgs.find(({id}) => id == data.reply_id) if (msg) msg.reply_num++; } }, @@ -1152,13 +1160,17 @@ export default { * 减少回复数量 * @param state * @param dispatch - * @param reply_id + * @param data {id, reply_id} */ - decrementMsgReplyNum({state, dispatch}, reply_id) { - $A.execMainDispatch("decrementMsgReplyNum", reply_id) + decrementMsgReplyNum({state, dispatch}, data) { + $A.execMainDispatch("decrementMsgReplyNum", data) // - if (reply_id > 0) { - const msg = state.dialogMsgs.find(({id}) => id == reply_id) + if ($A.execMainCacheJudge(`decrementMsgReplyNum:${data.id}`)) { + return + } + // + if (data.reply_id > 0) { + const msg = state.dialogMsgs.find(({id}) => id == data.reply_id) if (msg) msg.reply_num--; } }, @@ -2285,7 +2297,7 @@ export default { ids.some(id => { const index = state.dialogMsgs.findIndex(item => item.id == id); if (index > -1) { - dispatch("decrementMsgReplyNum", state.dialogMsgs[index].reply_id); + dispatch("decrementMsgReplyNum", state.dialogMsgs[index]); Store.set('audioSubscribe', id); state.dialogMsgs.splice(index, 1); } @@ -2604,9 +2616,9 @@ export default { case 'chat': if (!state.dialogMsgs.find(({id}) => id == data.id)) { // 新增任务消息数量 - dispatch("increaseTaskMsgNum", dialog_id); + dispatch("increaseTaskMsgNum", data); // 新增回复数量 - dispatch("increaseMsgReplyNum", data.reply_id); + dispatch("increaseMsgReplyNum", data); // if (mode === "chat") { return;