You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Review comments
This commit is contained in:
@ -584,7 +584,7 @@ describe("SlidingSync", () => {
|
|||||||
let txnId;
|
let txnId;
|
||||||
httpBackend.when("POST", syncUrl).check(function(req) {
|
httpBackend.when("POST", syncUrl).check(function(req) {
|
||||||
const body = req.data;
|
const body = req.data;
|
||||||
logger.log("txn got ", body);
|
logger.debug("got ", body);
|
||||||
expect(body.room_subscriptions).toBeTruthy();
|
expect(body.room_subscriptions).toBeTruthy();
|
||||||
expect(body.room_subscriptions[roomId]).toEqual(roomSubInfo);
|
expect(body.room_subscriptions[roomId]).toEqual(roomSubInfo);
|
||||||
expect(body.txn_id).toBeTruthy();
|
expect(body.txn_id).toBeTruthy();
|
||||||
@ -616,7 +616,7 @@ describe("SlidingSync", () => {
|
|||||||
let txnId;
|
let txnId;
|
||||||
httpBackend.when("POST", syncUrl).check(function(req) {
|
httpBackend.when("POST", syncUrl).check(function(req) {
|
||||||
const body = req.data;
|
const body = req.data;
|
||||||
logger.log("txn got ", body);
|
logger.debug("got ", body);
|
||||||
expect(body.room_subscriptions).toBeFalsy();
|
expect(body.room_subscriptions).toBeFalsy();
|
||||||
expect(body.lists[0]).toEqual(newList);
|
expect(body.lists[0]).toEqual(newList);
|
||||||
expect(body.txn_id).toBeTruthy();
|
expect(body.txn_id).toBeTruthy();
|
||||||
@ -638,7 +638,7 @@ describe("SlidingSync", () => {
|
|||||||
let txnId;
|
let txnId;
|
||||||
httpBackend.when("POST", syncUrl).check(function(req) {
|
httpBackend.when("POST", syncUrl).check(function(req) {
|
||||||
const body = req.data;
|
const body = req.data;
|
||||||
logger.log("txn got ", body);
|
logger.debug("got ", body);
|
||||||
expect(body.room_subscriptions).toBeFalsy();
|
expect(body.room_subscriptions).toBeFalsy();
|
||||||
expect(body.lists[0]).toEqual({
|
expect(body.lists[0]).toEqual({
|
||||||
ranges: [[20, 40]],
|
ranges: [[20, 40]],
|
||||||
@ -664,7 +664,7 @@ describe("SlidingSync", () => {
|
|||||||
let txnId;
|
let txnId;
|
||||||
httpBackend.when("POST", syncUrl).check(function(req) {
|
httpBackend.when("POST", syncUrl).check(function(req) {
|
||||||
const body = req.data;
|
const body = req.data;
|
||||||
logger.log("txn got ", body);
|
logger.debug("got ", body);
|
||||||
expect(body.room_subscriptions).toBeTruthy();
|
expect(body.room_subscriptions).toBeTruthy();
|
||||||
expect(body.room_subscriptions[roomId]).toEqual({
|
expect(body.room_subscriptions[roomId]).toEqual({
|
||||||
timeline_limit: 99,
|
timeline_limit: 99,
|
||||||
@ -759,7 +759,7 @@ describe("SlidingSync", () => {
|
|||||||
let txnId;
|
let txnId;
|
||||||
httpBackend.when("POST", syncUrl).check(function(req) {
|
httpBackend.when("POST", syncUrl).check(function(req) {
|
||||||
const body = req.data;
|
const body = req.data;
|
||||||
logger.log("txn got ", body);
|
logger.debug("got ", body);
|
||||||
expect(body.room_subscriptions).toBeFalsy();
|
expect(body.room_subscriptions).toBeFalsy();
|
||||||
expect(body.lists[0]).toEqual({
|
expect(body.lists[0]).toEqual({
|
||||||
ranges: [[20, 40]],
|
ranges: [[20, 40]],
|
||||||
|
@ -639,6 +639,10 @@ export class SlidingSync extends TypedEventEmitter<SlidingSyncEvent, SlidingSync
|
|||||||
* on failure.
|
* on failure.
|
||||||
*/
|
*/
|
||||||
public resend(): Promise<string> {
|
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.needsResend = true;
|
||||||
this.txnId = this.client.makeTxnId();
|
this.txnId = this.client.makeTxnId();
|
||||||
const d = defer<string>();
|
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,
|
// 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.
|
// then everything before it that hasn't been ACKed yet never will and we should reject them.
|
||||||
for (let i = 0; i < txnIndex; i++) {
|
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);
|
this.txnIdDefers[txnIndex].resolve(txnId);
|
||||||
// clear out settled promises, incuding the one we resolved.
|
// clear out settled promises, incuding the one we resolved.
|
||||||
|
Reference in New Issue
Block a user