1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Review comments

This commit is contained in:
Kegan Dougal
2022-08-10 11:53:13 +01:00
parent 2596999cb8
commit fa9f078a75
2 changed files with 10 additions and 8 deletions

View File

@@ -639,6 +639,10 @@ export class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSync
* on failure.
*/
public resend(): Promise<string> {
if (this.needsResend && this.txnIdDefers.length > 0) {
// we already have a resend queued, so just return the same promise
return this.txnIdDefers[this.txnIdDefers.length-1].promise;
}
this.needsResend = true;
this.txnId = this.client.makeTxnId();
const d = defer<string>();
@@ -671,9 +675,7 @@ export class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSync
// This list is sorted in time, so if the input txnId ACKs in the middle of this array,
// then everything before it that hasn't been ACKed yet never will and we should reject them.
for (let i = 0; i < txnIndex; i++) {
if (i < txnIndex) {
this.txnIdDefers[i].reject(this.txnIdDefers[i].txnId);
}
this.txnIdDefers[i].reject(this.txnIdDefers[i].txnId);
}
this.txnIdDefers[txnIndex].resolve(txnId);
// clear out settled promises, incuding the one we resolved.