perf: 优化重连时消息列表跳回第一页的情况

This commit is contained in:
kuaifan 2023-12-14 22:29:52 +08:00
parent aa70c41041
commit e5c622cb89

View File

@ -570,7 +570,6 @@ export default {
msgNew: 0, msgNew: 0,
msgType: '', msgType: '',
loadIng: 0, loadIng: 0,
unreadMsgId: 0,
allMsgs: [], allMsgs: [],
tempMsgs: [], tempMsgs: [],
@ -654,11 +653,13 @@ export default {
scrollTmp: 0, scrollTmp: 0,
scrollIng: 0, scrollIng: 0,
positionLoad: 0, approveDetails: {id: 0},
approveDetails:{id: 0},
approveDetailsShow: false, approveDetailsShow: false,
approvaUserStatus: '' approvaUserStatus: '',
positionLoad: 0, //
unreadMsgId: 0, // id
toBottomReGetMsg: false, //
} }
}, },
@ -997,6 +998,7 @@ export default {
this.msgType = '' this.msgType = ''
this.searchShow = false this.searchShow = false
this.unreadMsgId = 0 this.unreadMsgId = 0
this.toBottomReGetMsg = false
// //
if (this.allMsgList.length > 0) { if (this.allMsgList.length > 0) {
this.allMsgs = this.allMsgList this.allMsgs = this.allMsgList
@ -1114,11 +1116,15 @@ export default {
if (num <= 1) { if (num <= 1) {
return return
} }
this.getMsgs({ //
dialog_id: this.dialogId, const lastMsg = this.allMsgs[this.allMsgs.length - 1]
msg_id: this.msgId, const lastEl = $A(this.$refs.scroller.$el).find(`[data-id="${lastMsg.id}"]`)
msg_type: this.msgType, if (lastEl.length === 0) {
}).catch(_ => {}); this.toBottomReGetMsg = true
return;
}
//
this.onReGetMsg()
}, },
allMsgList(newList, oldList) { allMsgList(newList, oldList) {
@ -1936,6 +1942,15 @@ export default {
this.$store.dispatch("openOkr", this.dialogData.link_id); this.$store.dispatch("openOkr", this.dialogData.link_id);
}, },
onReGetMsg() {
this.toBottomReGetMsg = false
this.getMsgs({
dialog_id: this.dialogId,
msg_id: this.msgId,
msg_type: this.msgType,
}).catch(_ => {});
},
onPrevPage() { onPrevPage() {
if (this.prevId === 0) { if (this.prevId === 0) {
return return
@ -2228,6 +2243,7 @@ export default {
this.scrollTail = tail; this.scrollTail = tail;
if (this.scrollTail <= 55) { if (this.scrollTail <= 55) {
this.msgNew = 0; this.msgNew = 0;
this.toBottomReGetMsg && this.onReGetMsg()
} }
// //
this.scrollAction = event.target.scrollTop; this.scrollAction = event.target.scrollTop;