Commit d87adbfd authored by chenqikuai's avatar chenqikuai

fix: 修复handleEveryReceive函数在极短时间内多次调用会出现消息列表重复展示的问题

parent a5ccf151
...@@ -27,17 +27,20 @@ export default class ChatDBService { ...@@ -27,17 +27,20 @@ export default class ChatDBService {
isRoboot?: boolean isRoboot?: boolean
}) { }) {
let firstInsert = false let firstInsert = false
if (this.dataList.length === 0) { const isQueueEmpty = this.dataList.length === 0
if (isQueueEmpty) {
firstInsert = true firstInsert = true
} }
this.pushToList(data) this.pushToList(data)
if (firstInsert === true) { if (firstInsert === true) {
await this.exec(this.dataList[0])
this.dataList.shift()
this.startExecList() this.startExecList()
} }
} }
private async startExecList(): Promise<any> { private async startExecList(): Promise<any> {
if (this.dataList[0] !== undefined) { if (this.dataList.length !== 0) {
const msg = this.dataList[0] const msg = this.dataList[0]
await this.exec(msg) await this.exec(msg)
this.dataList.shift() this.dataList.shift()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment