You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Merge pull request #376 from matrix-org/rav/delay_otk_generation
Upload one-time keys on /sync rather than a timer
This commit is contained in:
@@ -303,17 +303,15 @@ MatrixClient.prototype.getDeviceEd25519Key = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Upload the device keys to the homeserver and ensure that the
|
||||
* homeserver has enough one-time keys.
|
||||
* @param {number} maxKeys The maximum number of keys to generate
|
||||
* Upload the device keys to the homeserver.
|
||||
* @return {object} A promise that will resolve when the keys are uploaded.
|
||||
*/
|
||||
MatrixClient.prototype.uploadKeys = function(maxKeys) {
|
||||
MatrixClient.prototype.uploadKeys = function() {
|
||||
if (this._crypto === null) {
|
||||
throw new Error("End-to-end encryption disabled");
|
||||
}
|
||||
|
||||
return this._crypto.uploadKeys(maxKeys);
|
||||
return this._crypto.uploadDeviceKeys();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2690,12 +2688,7 @@ MatrixClient.prototype.startClient = function(opts) {
|
||||
}
|
||||
|
||||
if (this._crypto) {
|
||||
this._crypto.uploadKeys(5).done();
|
||||
const tenMinutes = 1000 * 60 * 10;
|
||||
const self = this;
|
||||
this._uploadIntervalID = global.setInterval(function() {
|
||||
self._crypto.uploadKeys(5).done();
|
||||
}, tenMinutes);
|
||||
this._crypto.uploadDeviceKeys().done();
|
||||
}
|
||||
|
||||
// periodically poll for turn servers if we support voip
|
||||
@@ -2729,9 +2722,6 @@ MatrixClient.prototype.stopClient = function() {
|
||||
this._syncApi.stop();
|
||||
this._syncApi = null;
|
||||
}
|
||||
if (this._crypto) {
|
||||
global.clearInterval(this._uploadIntervalID);
|
||||
}
|
||||
global.clearTimeout(this._checkTurnServersTimeoutID);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user