diff --git a/src/autodiscovery.ts b/src/autodiscovery.ts index 5c19e6611..c60bd0529 100644 --- a/src/autodiscovery.ts +++ b/src/autodiscovery.ts @@ -249,21 +249,20 @@ export class AutoDiscovery { // Step 7: Copy any other keys directly into the clientConfig. This is for // things like custom configuration of services. - Object.keys(wellknown) - .map((k) => { - if (k === "m.homeserver" || k === "m.identity_server") { - // Only copy selected parts of the config to avoid overwriting - // properties computed by the validation logic above. - const notProps = ["error", "state", "base_url"]; - for (const prop of Object.keys(wellknown[k])) { - if (notProps.includes(prop)) continue; - clientConfig[k][prop] = wellknown[k][prop]; - } - } else { - // Just copy the whole thing over otherwise - clientConfig[k] = wellknown[k]; + Object.keys(wellknown).forEach((k) => { + if (k === "m.homeserver" || k === "m.identity_server") { + // Only copy selected parts of the config to avoid overwriting + // properties computed by the validation logic above. + const notProps = ["error", "state", "base_url"]; + for (const prop of Object.keys(wellknown[k])) { + if (notProps.includes(prop)) continue; + clientConfig[k][prop] = wellknown[k][prop]; } - }); + } else { + // Just copy the whole thing over otherwise + clientConfig[k] = wellknown[k]; + } + }); // Step 8: Give the config to the caller (finally) return Promise.resolve(clientConfig); diff --git a/src/client.ts b/src/client.ts index c745af5f9..e7b183bd2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -3415,7 +3415,9 @@ export class MatrixClient extends TypedEventEmitter { const content = { ignored_users: {} }; - userIds.map((u) => content.ignored_users[u] = {}); + userIds.forEach((u) => { + content.ignored_users[u] = {}; + }); return this.setAccountData("m.ignored_user_list", content, callback); } diff --git a/src/crypto/DeviceList.ts b/src/crypto/DeviceList.ts index 1de1f9894..5fdae5c24 100644 --- a/src/crypto/DeviceList.ts +++ b/src/crypto/DeviceList.ts @@ -309,10 +309,10 @@ export class DeviceList extends TypedEventEmitter { + userIds.forEach((u) => { stored[u] = {}; const devices = this.getStoredDevicesForUser(u) || []; - devices.map(function(dev) { + devices.forEach(function(dev) { stored[u][dev.deviceId] = dev; }); }); diff --git a/src/crypto/backup.ts b/src/crypto/backup.ts index f3a6824d1..eddbabe11 100644 --- a/src/crypto/backup.ts +++ b/src/crypto/backup.ts @@ -375,9 +375,7 @@ export class BackupManager { ); if (device) { sigInfo.device = device; - sigInfo.deviceTrust = await this.baseApis.checkDeviceTrust( - this.baseApis.getUserId(), sigInfo.deviceId, - ); + sigInfo.deviceTrust = this.baseApis.checkDeviceTrust(this.baseApis.getUserId(), sigInfo.deviceId); try { await verifySignature( this.baseApis.crypto.olmDevice, @@ -495,7 +493,7 @@ export class BackupManager { rooms[roomId] = { sessions: {} }; } - const sessionData = await this.baseApis.crypto.olmDevice.exportInboundGroupSession( + const sessionData = this.baseApis.crypto.olmDevice.exportInboundGroupSession( session.senderKey, session.sessionId, session.sessionData, ); sessionData.algorithm = MEGOLM_ALGORITHM; diff --git a/src/crypto/index.ts b/src/crypto/index.ts index 3a738da31..201545e80 100644 --- a/src/crypto/index.ts +++ b/src/crypto/index.ts @@ -1026,7 +1026,7 @@ export class Crypto extends TypedEventEmitter { + private cancelOnTimeout = async () => { try { if (this.initiatedByMe) { - this.cancel({ + await this.cancel({ reason: "Other party didn't accept in time", code: "m.timeout", }); } else { - this.cancel({ + await this.cancel({ reason: "User didn't accept in time", code: "m.timeout", }); diff --git a/src/http-api.ts b/src/http-api.ts index 0b8cd41c8..5ee24312a 100644 --- a/src/http-api.ts +++ b/src/http-api.ts @@ -1105,7 +1105,7 @@ export class AbortError extends Error { * @return {any} the result of the network operation * @throws {ConnectionError} If after maxAttempts the callback still throws ConnectionError */ -export async function retryNetworkOperation(maxAttempts: number, callback: () => T): Promise { +export async function retryNetworkOperation(maxAttempts: number, callback: () => Promise): Promise { let attempts = 0; let lastConnectionError = null; while (attempts < maxAttempts) { diff --git a/src/store/indexeddb-local-backend.ts b/src/store/indexeddb-local-backend.ts index 3812cc953..a7a7e2574 100644 --- a/src/store/indexeddb-local-backend.ts +++ b/src/store/indexeddb-local-backend.ts @@ -530,9 +530,7 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend { const txn = this.db.transaction(["client_options"], "readonly"); const store = txn.objectStore("client_options"); return selectQuery(store, undefined, (cursor) => { - if (cursor.value && cursor.value && cursor.value.options) { - return cursor.value.options; - } + return cursor.value?.options; }).then((results) => results[0]); }); } diff --git a/src/utils.ts b/src/utils.ts index 80929c36e..95e415502 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -464,7 +464,7 @@ export function defer(): IDeferred { } export async function promiseMapSeries( - promises: T[], + promises: Array>, fn: (t: T) => void, ): Promise { for (const o of promises) {