perf: 优化网络重连后会话数据逻辑

This commit is contained in:
kuaifan 2024-05-30 19:02:58 +08:00
parent bc7874a3a0
commit e24b6806da

View File

@ -781,6 +781,7 @@ export default {
forwardSource: true, forwardSource: true,
openId: 0, openId: 0,
errorId: 0,
dialogDrag: false, dialogDrag: false,
groupInfoShow: false, groupInfoShow: false,
reportShow: false, reportShow: false,
@ -1238,43 +1239,7 @@ export default {
dialogId: { dialogId: {
handler(dialog_id, old_id) { handler(dialog_id, old_id) {
if (dialog_id) { this.getDialogBase(dialog_id)
this.msgNew = 0
this.msgType = ''
this.unreadOne = 0
this.scrollTail = 0
this.scrollOffset = 0
this.searchShow = false
this.positionShow = false
this.msgPrepared = false
this.scrollToBottomRefresh = false
this.allMsgs = this.allMsgList
//
this.getMsgs({
dialog_id,
msg_id: this.msgId,
msg_type: this.msgType,
}).then(_ => {
this.openId = dialog_id
this.msgPrepared = true
//
setTimeout(_ => {
this.onSearchMsgId()
this.positionShow = this.readTimeout === null
}, 100)
}).catch(_ => {});
//
this.$store.dispatch('saveInDialog', {
uid: this._uid,
dialog_id,
})
//
if (this.autoFocus) {
this.inputFocus()
}
//
this.getUserApproveStatus()
}
// //
this.$store.dispatch('closeDialog', old_id) this.$store.dispatch('closeDialog', old_id)
// //
@ -1408,7 +1373,11 @@ export default {
return; return;
} }
// //
this.onReGetMsg() if (this.errorId === this.dialogId) {
this.getDialogBase(this.dialogId)
} else {
this.onReGetMsg()
}
}, },
allMsgList(list) { allMsgList(list) {
@ -1497,6 +1466,55 @@ export default {
}, },
methods: { methods: {
/**
* 获取会话基本信息
* @param dialog_id
*/
getDialogBase(dialog_id) {
if (!dialog_id) {
return
}
this.msgNew = 0
this.msgType = ''
this.unreadOne = 0
this.scrollTail = 0
this.scrollOffset = 0
this.searchShow = false
this.positionShow = false
this.msgPrepared = false
this.scrollToBottomRefresh = false
this.allMsgs = this.allMsgList
this.errorId = 0
//
this.getMsgs({
dialog_id,
msg_id: this.msgId,
msg_type: this.msgType,
}).then(_ => {
this.openId = dialog_id
this.msgPrepared = true
//
setTimeout(_ => {
this.onSearchMsgId()
this.positionShow = this.readTimeout === null
}, 100)
}).catch(_ => {
this.errorId = dialog_id
});
//
this.$store.dispatch('saveInDialog', {
uid: this._uid,
dialog_id,
})
//
if (this.autoFocus) {
this.inputFocus()
}
//
this.getUserApproveStatus()
},
/** /**
* 订阅消息用于独立窗口 * 订阅消息用于独立窗口
* @param unsubscribe * @param unsubscribe