1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Make some of DeviceList asynchronous

* DeviceList._updateStoredDeviceKeysForUser
 * DeviceList._processQueryResponseForUser
 * DeviceList._storeDeviceKeys
This commit is contained in:
Richard van der Hoff
2017-07-26 08:04:46 +01:00
parent 951df61aa0
commit 0943e0c60f

View File

@@ -462,7 +462,7 @@ class DeviceListUpdateSerialiser {
let prom = Promise.resolve();
for (const userId of downloadUsers) {
prom = prom.delay(5).then(() => {
this._processQueryResponseForUser(userId, dk[userId]);
return this._processQueryResponseForUser(userId, dk[userId]);
});
}
@@ -486,7 +486,7 @@ class DeviceListUpdateSerialiser {
return deferred.promise;
}
_processQueryResponseForUser(userId, response) {
async _processQueryResponseForUser(userId, response) {
console.log('got keys for ' + userId + ':', response);
// map from deviceid -> deviceinfo for this user
@@ -499,7 +499,7 @@ class DeviceListUpdateSerialiser {
});
}
_updateStoredDeviceKeysForUser(
await _updateStoredDeviceKeysForUser(
this._olmDevice, userId, userStore, response || {},
);
@@ -516,7 +516,7 @@ class DeviceListUpdateSerialiser {
}
function _updateStoredDeviceKeysForUser(_olmDevice, userId, userStore,
async function _updateStoredDeviceKeysForUser(_olmDevice, userId, userStore,
userResult) {
let updated = false;
@@ -554,7 +554,7 @@ function _updateStoredDeviceKeysForUser(_olmDevice, userId, userStore,
continue;
}
if (_storeDeviceKeys(_olmDevice, userStore, deviceResult)) {
if (await _storeDeviceKeys(_olmDevice, userStore, deviceResult)) {
updated = true;
}
}
@@ -565,9 +565,9 @@ function _updateStoredDeviceKeysForUser(_olmDevice, userId, userStore,
/*
* Process a device in a /query response, and add it to the userStore
*
* returns true if a change was made, else false
* returns (a promise for) true if a change was made, else false
*/
function _storeDeviceKeys(_olmDevice, userStore, deviceResult) {
async function _storeDeviceKeys(_olmDevice, userStore, deviceResult) {
if (!deviceResult.keys) {
// no keys?
return false;