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