You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Apply corrections identified by SonarQube (#2336)
* Apply corrections identified by SonarQube * Apply corrections identified by SonarQube * Make type more flexible
This commit is contained in:
committed by
GitHub
parent
6137afeb28
commit
b896111269
@@ -249,8 +249,7 @@ 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) => {
|
||||
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.
|
||||
|
||||
@@ -3415,7 +3415,9 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
*/
|
||||
public setIgnoredUsers(userIds: string[], callback?: Callback): Promise<{}> {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -309,10 +309,10 @@ export class DeviceList extends TypedEventEmitter<EmittedEvents, CryptoEventHand
|
||||
*/
|
||||
private getDevicesFromStore(userIds: string[]): DeviceInfoMap {
|
||||
const stored: DeviceInfoMap = {};
|
||||
userIds.map((u) => {
|
||||
userIds.forEach((u) => {
|
||||
stored[u] = {};
|
||||
const devices = this.getStoredDevicesForUser(u) || [];
|
||||
devices.map(function(dev) {
|
||||
devices.forEach(function(dev) {
|
||||
stored[u][dev.deviceId] = dev;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1026,7 +1026,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
||||
const decodedBackupKey = new Uint8Array(olmlib.decodeBase64(
|
||||
fixedBackupKey || sessionBackupKey,
|
||||
));
|
||||
await builder.addSessionBackupPrivateKeyToCache(decodedBackupKey);
|
||||
builder.addSessionBackupPrivateKeyToCache(decodedBackupKey);
|
||||
} else if (this.backupManager.getKeyBackupEnabled()) {
|
||||
// key backup is enabled but we don't have a session backup key in SSSS: see if we have one in
|
||||
// the cache or the user can provide one, and if so, write it to SSSS
|
||||
|
||||
@@ -796,8 +796,7 @@ export class VerificationRequest<
|
||||
}
|
||||
|
||||
private setupTimeout(phase: Phase): void {
|
||||
const shouldTimeout = !this.timeoutTimer && !this.observeOnly &&
|
||||
phase === PHASE_REQUESTED;
|
||||
const shouldTimeout = !this.timeoutTimer && !this.observeOnly && phase === PHASE_REQUESTED;
|
||||
|
||||
if (shouldTimeout) {
|
||||
this.timeoutTimer = setTimeout(this.cancelOnTimeout, this.timeout);
|
||||
@@ -814,15 +813,15 @@ export class VerificationRequest<
|
||||
}
|
||||
}
|
||||
|
||||
private cancelOnTimeout = () => {
|
||||
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",
|
||||
});
|
||||
|
||||
@@ -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<T>(maxAttempts: number, callback: () => T): Promise<T> {
|
||||
export async function retryNetworkOperation<T>(maxAttempts: number, callback: () => Promise<T>): Promise<T> {
|
||||
let attempts = 0;
|
||||
let lastConnectionError = null;
|
||||
while (attempts < maxAttempts) {
|
||||
|
||||
@@ -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]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ export function defer<T = void>(): IDeferred<T> {
|
||||
}
|
||||
|
||||
export async function promiseMapSeries<T>(
|
||||
promises: T[],
|
||||
promises: Array<T | Promise<T>>,
|
||||
fn: (t: T) => void,
|
||||
): Promise<void> {
|
||||
for (const o of promises) {
|
||||
|
||||
Reference in New Issue
Block a user