Merge pull request #243 from vector-im/bwindels/fix-send-queue-skip
Prevent pending events being skipped when remote echo comes
This commit is contained in:
commit
6921e9cd21
1 changed files with 15 additions and 2 deletions
|
@ -46,13 +46,26 @@ export class SendQueue {
|
|||
this._roomEncryption = roomEncryption;
|
||||
}
|
||||
|
||||
_nextPendingEvent(current) {
|
||||
if (!current) {
|
||||
return this._pendingEvents.get(0);
|
||||
} else {
|
||||
const idx = this._pendingEvents.indexOf(current);
|
||||
if (idx !== -1) {
|
||||
return this._pendingEvents.get(idx + 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_sendLoop(log) {
|
||||
this._isSending = true;
|
||||
this._sendLoopLogItem = log.runDetached("send queue flush", async log => {
|
||||
let pendingEvent;
|
||||
try {
|
||||
for (let i = 0; i < this._pendingEvents.length; i += 1) {
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while (pendingEvent = this._nextPendingEvent(pendingEvent)) {
|
||||
await log.wrap("send event", async log => {
|
||||
const pendingEvent = this._pendingEvents.get(i);
|
||||
log.set("queueIndex", pendingEvent.queueIndex);
|
||||
try {
|
||||
await this._sendEvent(pendingEvent, log);
|
||||
|
|
Reference in a new issue