diff --git a/spec/unit/crypto/DeviceList.spec.js b/spec/unit/crypto/DeviceList.spec.js index 870e40bbc..5a442d81b 100644 --- a/spec/unit/crypto/DeviceList.spec.js +++ b/spec/unit/crypto/DeviceList.spec.js @@ -59,16 +59,25 @@ describe('DeviceList', function() { let downloadSpy; let sessionStore; let cryptoStore; + let deviceLists = []; beforeEach(function() { testUtils.beforeEach(this); // eslint-disable-line no-invalid-this + deviceLists = []; + downloadSpy = expect.createSpy(); const mockStorage = new MockStorageApi(); sessionStore = new WebStorageSessionStore(mockStorage); cryptoStore = new MemoryCryptoStore(); }); + afterEach(function() { + for (const dl of deviceLists) { + dl.stop(); + } + }); + function createTestDeviceList() { const baseApis = { downloadKeysForUsers: downloadSpy, @@ -76,7 +85,9 @@ describe('DeviceList', function() { const mockOlm = { verifySignature: function(key, message, signature) {}, }; - return new DeviceList(baseApis, cryptoStore, sessionStore, mockOlm); + const dl = new DeviceList(baseApis, cryptoStore, sessionStore, mockOlm); + deviceLists.push(dl); + return dl; } it("should successfully download and store device keys", function() { diff --git a/src/crypto/DeviceList.js b/src/crypto/DeviceList.js index 853299f31..e85cb7ef3 100644 --- a/src/crypto/DeviceList.js +++ b/src/crypto/DeviceList.js @@ -162,6 +162,12 @@ export default class DeviceList { } } + stop() { + if (this._saveTimer !== null) { + clearTimeout(this._saveTimer); + } + } + /** * Save the device tracking state to storage, if any changes are * pending other than updating the sync token diff --git a/src/crypto/index.js b/src/crypto/index.js index 70a398078..655a801dc 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -338,6 +338,7 @@ Crypto.prototype.start = function() { /** Stop background processes related to crypto */ Crypto.prototype.stop = function() { this._outgoingRoomKeyRequestManager.stop(); + this._deviceList.stop(); }; /**