Skip to content

Commit fa9f078

Browse files
committed
Review comments
1 parent 2596999 commit fa9f078

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

spec/integ/sliding-sync.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ describe("SlidingSync", () => {
584584
let txnId;
585585
httpBackend.when("POST", syncUrl).check(function(req) {
586586
const body = req.data;
587-
logger.log("txn got ", body);
587+
logger.debug("got ", body);
588588
expect(body.room_subscriptions).toBeTruthy();
589589
expect(body.room_subscriptions[roomId]).toEqual(roomSubInfo);
590590
expect(body.txn_id).toBeTruthy();
@@ -616,7 +616,7 @@ describe("SlidingSync", () => {
616616
let txnId;
617617
httpBackend.when("POST", syncUrl).check(function(req) {
618618
const body = req.data;
619-
logger.log("txn got ", body);
619+
logger.debug("got ", body);
620620
expect(body.room_subscriptions).toBeFalsy();
621621
expect(body.lists[0]).toEqual(newList);
622622
expect(body.txn_id).toBeTruthy();
@@ -638,7 +638,7 @@ describe("SlidingSync", () => {
638638
let txnId;
639639
httpBackend.when("POST", syncUrl).check(function(req) {
640640
const body = req.data;
641-
logger.log("txn got ", body);
641+
logger.debug("got ", body);
642642
expect(body.room_subscriptions).toBeFalsy();
643643
expect(body.lists[0]).toEqual({
644644
ranges: [[20, 40]],
@@ -664,7 +664,7 @@ describe("SlidingSync", () => {
664664
let txnId;
665665
httpBackend.when("POST", syncUrl).check(function(req) {
666666
const body = req.data;
667-
logger.log("txn got ", body);
667+
logger.debug("got ", body);
668668
expect(body.room_subscriptions).toBeTruthy();
669669
expect(body.room_subscriptions[roomId]).toEqual({
670670
timeline_limit: 99,
@@ -759,7 +759,7 @@ describe("SlidingSync", () => {
759759
let txnId;
760760
httpBackend.when("POST", syncUrl).check(function(req) {
761761
const body = req.data;
762-
logger.log("txn got ", body);
762+
logger.debug("got ", body);
763763
expect(body.room_subscriptions).toBeFalsy();
764764
expect(body.lists[0]).toEqual({
765765
ranges: [[20, 40]],

src/sliding-sync.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ export class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSync
639639
* on failure.
640640
*/
641641
public resend(): Promise<string> {
642+
if (this.needsResend && this.txnIdDefers.length > 0) {
643+
// we already have a resend queued, so just return the same promise
644+
return this.txnIdDefers[this.txnIdDefers.length-1].promise;
645+
}
642646
this.needsResend = true;
643647
this.txnId = this.client.makeTxnId();
644648
const d = defer<string>();
@@ -671,9 +675,7 @@ export class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSync
671675
// This list is sorted in time, so if the input txnId ACKs in the middle of this array,
672676
// then everything before it that hasn't been ACKed yet never will and we should reject them.
673677
for (let i = 0; i < txnIndex; i++) {
674-
if (i < txnIndex) {
675-
this.txnIdDefers[i].reject(this.txnIdDefers[i].txnId);
676-
}
678+
this.txnIdDefers[i].reject(this.txnIdDefers[i].txnId);
677679
}
678680
this.txnIdDefers[txnIndex].resolve(txnId);
679681
// clear out settled promises, incuding the one we resolved.

0 commit comments

Comments
 (0)