mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-28 12:50:48 +00:00
解决消息筛选时计算错误的情况
This commit is contained in:
parent
69fb875421
commit
b73e1c27eb
@ -441,17 +441,22 @@ export default {
|
||||
},
|
||||
|
||||
allMsgList() {
|
||||
const dialogMsgList = this.dialogMsgList.filter(item => this.msgFilter(item)).sort((a, b) => {
|
||||
return a.id - b.id;
|
||||
})
|
||||
const tempMsgList = this.tempMsgList.filter(item => this.msgFilter(item))
|
||||
if (tempMsgList.length > 0) {
|
||||
const array = [];
|
||||
array.push(...dialogMsgList);
|
||||
array.push(...tempMsgList)
|
||||
return array;
|
||||
const dialogMsgList = this.dialogMsgList.filter(item => this.msgFilter(item))
|
||||
if (this.tempMsgList.length > 0) {
|
||||
const ids = dialogMsgList.map(({id}) => id)
|
||||
const tempMsgList = this.tempMsgList.filter(item => !ids.includes(item.id) && this.msgFilter(item))
|
||||
if (tempMsgList.length > 0) {
|
||||
const array = [];
|
||||
array.push(...dialogMsgList);
|
||||
array.push(...tempMsgList)
|
||||
return array.sort((a, b) => {
|
||||
return a.id - b.id;
|
||||
});
|
||||
}
|
||||
}
|
||||
return dialogMsgList;
|
||||
return dialogMsgList.sort((a, b) => {
|
||||
return a.id - b.id;
|
||||
});
|
||||
},
|
||||
|
||||
loadMsg() {
|
||||
@ -596,13 +601,22 @@ export default {
|
||||
immediate: true
|
||||
},
|
||||
|
||||
msgType(type) {
|
||||
msgType(msg_type) {
|
||||
this.tempMsgs = this.tempMsgs.filter(({is_msg_type}) => is_msg_type !== true)
|
||||
requestAnimationFrame(this.onToBottom)
|
||||
if (type) {
|
||||
//
|
||||
if (msg_type) {
|
||||
this.$store.dispatch("getDialogMsgs", {
|
||||
dialog_id: this.dialogId,
|
||||
msg_id: this.msgId,
|
||||
msg_type: this.msgType,
|
||||
msg_type,
|
||||
save_cancel: true,
|
||||
}).then(({data}) => {
|
||||
if (data.list.length > 0) {
|
||||
this.tempMsgs.push(...data.list.map(item => Object.assign(item, {
|
||||
is_msg_type: true
|
||||
})))
|
||||
}
|
||||
}).catch(_ => {});
|
||||
}
|
||||
},
|
||||
|
||||
27
resources/assets/js/store/actions.js
vendored
27
resources/assets/js/store/actions.js
vendored
@ -2183,7 +2183,7 @@ export default {
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @param getters
|
||||
* @param data {dialog_id, msg_id, ?msg_type, ?position_id, ?prev_id, ?next_id, ?save_before, ?save_after}
|
||||
* @param data {dialog_id, msg_id, ?msg_type, ?position_id, ?prev_id, ?next_id, ?save_before, ?save_cancel}
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
getDialogMsgs({state, dispatch, getters}, data) {
|
||||
@ -2195,9 +2195,9 @@ export default {
|
||||
}
|
||||
//
|
||||
const saveBefore = typeof data.save_before === "function" ? data.save_before : _ => {}
|
||||
const saveAfter = typeof data.save_after === "function" ? data.save_after : _ => {}
|
||||
const saveCancel = typeof data.save_cancel === "boolean" ? data.save_cancel : false
|
||||
if (typeof data.save_before !== "undefined") delete data.save_before
|
||||
if (typeof data.save_after !== "undefined") delete data.save_after
|
||||
if (typeof data.save_cancel !== "undefined") delete data.save_cancel
|
||||
//
|
||||
const loadKey = `msg::${data.dialog_id}-${data.msg_id}-${data.msg_type || ''}`
|
||||
if (getters.isLoad(loadKey)) {
|
||||
@ -2211,17 +2211,18 @@ export default {
|
||||
data,
|
||||
complete: _ => dispatch("cancelLoad", loadKey)
|
||||
}).then(result => {
|
||||
const resData = result.data;
|
||||
if ($A.isJson(resData.dialog)) {
|
||||
dispatch("saveDialog", resData.dialog);
|
||||
//
|
||||
const ids = resData.list.map(({id}) => id)
|
||||
state.dialogMsgs = state.dialogMsgs.filter(item => item.dialog_id != data.dialog_id || ids.includes(item.id));
|
||||
}
|
||||
//
|
||||
saveBefore()
|
||||
dispatch("saveDialogMsg", resData.list)
|
||||
saveAfter()
|
||||
if (!saveCancel) {
|
||||
const resData = result.data;
|
||||
if ($A.isJson(resData.dialog)) {
|
||||
dispatch("saveDialog", resData.dialog);
|
||||
//
|
||||
const ids = resData.list.map(({id}) => id)
|
||||
state.dialogMsgs = state.dialogMsgs.filter(item => item.dialog_id != data.dialog_id || ids.includes(item.id));
|
||||
}
|
||||
//
|
||||
dispatch("saveDialogMsg", resData.list)
|
||||
}
|
||||
resolve(result)
|
||||
}).catch(e => {
|
||||
console.warn(e);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user