You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Stop devicelist when client is stopped
To avoid the devicelist trying to save after the client has been stopped Hopefully will fix random test failures on node 11.
This commit is contained in:
@@ -59,16 +59,25 @@ describe('DeviceList', function() {
|
|||||||
let downloadSpy;
|
let downloadSpy;
|
||||||
let sessionStore;
|
let sessionStore;
|
||||||
let cryptoStore;
|
let cryptoStore;
|
||||||
|
let deviceLists = [];
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
testUtils.beforeEach(this); // eslint-disable-line no-invalid-this
|
testUtils.beforeEach(this); // eslint-disable-line no-invalid-this
|
||||||
|
|
||||||
|
deviceLists = [];
|
||||||
|
|
||||||
downloadSpy = expect.createSpy();
|
downloadSpy = expect.createSpy();
|
||||||
const mockStorage = new MockStorageApi();
|
const mockStorage = new MockStorageApi();
|
||||||
sessionStore = new WebStorageSessionStore(mockStorage);
|
sessionStore = new WebStorageSessionStore(mockStorage);
|
||||||
cryptoStore = new MemoryCryptoStore();
|
cryptoStore = new MemoryCryptoStore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
for (const dl of deviceLists) {
|
||||||
|
dl.stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function createTestDeviceList() {
|
function createTestDeviceList() {
|
||||||
const baseApis = {
|
const baseApis = {
|
||||||
downloadKeysForUsers: downloadSpy,
|
downloadKeysForUsers: downloadSpy,
|
||||||
@@ -76,7 +85,9 @@ describe('DeviceList', function() {
|
|||||||
const mockOlm = {
|
const mockOlm = {
|
||||||
verifySignature: function(key, message, signature) {},
|
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() {
|
it("should successfully download and store device keys", function() {
|
||||||
|
|||||||
@@ -146,6 +146,12 @@ export default class DeviceList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if (this._saveTimer !== null) {
|
||||||
|
clearTimeout(this._saveTimer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the device tracking state to storage, if any changes are
|
* Save the device tracking state to storage, if any changes are
|
||||||
* pending other than updating the sync token
|
* pending other than updating the sync token
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ Crypto.prototype.start = function() {
|
|||||||
/** Stop background processes related to crypto */
|
/** Stop background processes related to crypto */
|
||||||
Crypto.prototype.stop = function() {
|
Crypto.prototype.stop = function() {
|
||||||
this._outgoingRoomKeyRequestManager.stop();
|
this._outgoingRoomKeyRequestManager.stop();
|
||||||
|
this._deviceList.stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user