simplify this code now that it is only doing one thing

This commit is contained in:
Bruno Windels 2021-03-09 12:27:51 +01:00
parent f9979b1a77
commit 0b211e8e1c

View file

@ -441,7 +441,6 @@ export class Session {
/** @internal */
async afterSyncCompleted(changes, isCatchupSync, log) {
const promises = [];
// we don't start uploading one-time keys until we've caught up with
// to-device messages, to help us avoid throwing away one-time-keys that we
// are about to receive messages for
@ -449,13 +448,9 @@ export class Session {
if (!isCatchupSync) {
const needsToUploadOTKs = await this._e2eeAccount.generateOTKsIfNeeded(this._storage, log);
if (needsToUploadOTKs) {
promises.push(log.wrap("uploadKeys", log => this._e2eeAccount.uploadKeys(this._storage, log)));
await log.wrap("uploadKeys", log => this._e2eeAccount.uploadKeys(this._storage, log));
}
}
if (promises.length) {
// run key upload and decryption in parallel
await Promise.all(promises);
}
}
/** @internal */