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