diff --git a/spec/unit/matrix-client.spec.ts b/spec/unit/matrix-client.spec.ts index 702c22c05f4..d1d0bf5baaf 100644 --- a/spec/unit/matrix-client.spec.ts +++ b/spec/unit/matrix-client.spec.ts @@ -427,7 +427,7 @@ describe("MatrixClient", function() { } }); }); - await client.startClient(); + await client.startClient({ filter }); await syncPromise; }); diff --git a/spec/unit/utils.spec.ts b/spec/unit/utils.spec.ts index 36ad9e164bc..be30890edea 100644 --- a/spec/unit/utils.spec.ts +++ b/spec/unit/utils.spec.ts @@ -152,6 +152,9 @@ describe("utils", function() { assert.isTrue(utils.deepCompare({ a: 1, b: 2 }, { a: 1, b: 2 })); assert.isTrue(utils.deepCompare({ a: 1, b: 2 }, { b: 2, a: 1 })); assert.isFalse(utils.deepCompare({ a: 1, b: 2 }, { a: 1, b: 3 })); + assert.isFalse(utils.deepCompare({ a: 1, b: 2 }, { a: 1 })); + assert.isFalse(utils.deepCompare({ a: 1 }, { a: 1, b: 2 })); + assert.isFalse(utils.deepCompare({ a: 1 }, { b: 1 })); assert.isTrue(utils.deepCompare({ 1: { name: "mhc", age: 28 }, diff --git a/src/sync.ts b/src/sync.ts index 430e0260229..396b5ba45d3 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -102,7 +102,7 @@ const MSC2716_ROOM_VERSIONS = [ function getFilterName(userId: string, suffix?: string): string { // scope this on the user ID because people may login on many accounts // and they all need to be stored! - return `FILTER_SYNC_${userId}` + suffix ? "_" + suffix : ""; + return `FILTER_SYNC_${userId}` + (suffix ? "_" + suffix : ""); } function debuglog(...params) { diff --git a/src/utils.ts b/src/utils.ts index f9c087fd93a..ffb438d5b90 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -238,33 +238,24 @@ export function deepCompare(x: any, y: any): boolean { } } } else { - // disable jshint "The body of a for in should be wrapped in an if - // statement" - /* jshint -W089 */ - // check that all of y's direct keys are in x - let p; - for (p in y) { + for (const p in y) { if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) { return false; } } // finally, compare each of x's keys with y - for (p in y) { // eslint-disable-line guard-for-in - if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) { - return false; - } - if (!deepCompare(x[p], y[p])) { + for (const p in x) { + if (y.hasOwnProperty(p) !== x.hasOwnProperty(p) || !deepCompare(x[p], y[p])) { return false; } } } - /* jshint +W089 */ return true; } -// Dev note: This returns a tuple, but jsdoc doesn't like that. https://github.com/jsdoc/jsdoc/issues/1703 +// Dev note: This returns an array of tuples, but jsdoc doesn't like that. https://github.com/jsdoc/jsdoc/issues/1703 /** * Creates an array of object properties/values (entries) then * sorts the result by key, recursively. The input object must