You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-23 17:02:25 +03:00
Another SonarQube happiness pass (#2347)
This commit is contained in:
committed by
GitHub
parent
a388fde3e2
commit
dea3f52fe9
@@ -1296,9 +1296,9 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
* Get the current dehydrated device, if any
|
||||
* @return {Promise} A promise of an object containing the dehydrated device
|
||||
*/
|
||||
public getDehydratedDevice(): Promise<IDehydratedDevice> {
|
||||
public async getDehydratedDevice(): Promise<IDehydratedDevice> {
|
||||
try {
|
||||
return this.http.authedRequest<IDehydratedDevice>(
|
||||
return await this.http.authedRequest<IDehydratedDevice>(
|
||||
undefined,
|
||||
Method.Get,
|
||||
"/dehydrated_device",
|
||||
@@ -3365,7 +3365,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
* data event.
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
public getAccountDataFromServer<T extends {[k: string]: any}>(eventType: string): Promise<T> {
|
||||
public async getAccountDataFromServer<T extends {[k: string]: any}>(eventType: string): Promise<T> {
|
||||
if (this.isInitialSyncComplete()) {
|
||||
const event = this.store.getAccountData(eventType);
|
||||
if (!event) {
|
||||
@@ -3380,11 +3380,9 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
$type: eventType,
|
||||
});
|
||||
try {
|
||||
return this.http.authedRequest(
|
||||
undefined, Method.Get, path, undefined,
|
||||
);
|
||||
return await this.http.authedRequest(undefined, Method.Get, path);
|
||||
} catch (e) {
|
||||
if (e.data && e.data.errcode === 'M_NOT_FOUND') {
|
||||
if (e.data?.errcode === 'M_NOT_FOUND') {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
@@ -4851,7 +4849,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
}
|
||||
}
|
||||
|
||||
const populationResults: Record<string, Error> = {}; // {roomId: Error}
|
||||
const populationResults: { [roomId: string]: Error } = {};
|
||||
const promises = [];
|
||||
|
||||
const doLeave = (roomId: string) => {
|
||||
@@ -5875,7 +5873,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
*/
|
||||
public setRoomMutePushRule(scope: string, roomId: string, mute: boolean): Promise<void> | void {
|
||||
let promise: Promise<void>;
|
||||
let hasDontNotifyRule;
|
||||
let hasDontNotifyRule = false;
|
||||
|
||||
// Get the existing room-kind push rule if any
|
||||
const roomPushRule = this.getRoomPushRule(scope, roomId);
|
||||
@@ -5928,7 +5926,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
});
|
||||
}).catch((err: Error) => {
|
||||
// Update it even if the previous operation fails. This can help the
|
||||
// app to recover when push settings has been modifed from another client
|
||||
// app to recover when push settings has been modified from another client
|
||||
this.getPushRules().then((result) => {
|
||||
this.pushRules = result;
|
||||
reject(err);
|
||||
|
||||
@@ -122,7 +122,7 @@ export class DeviceList extends TypedEventEmitter<EmittedEvents, CryptoEventHand
|
||||
'readonly', [IndexedDBCryptoStore.STORE_DEVICE_DATA], (txn) => {
|
||||
this.cryptoStore.getEndToEndDeviceData(txn, (deviceData) => {
|
||||
this.hasFetched = Boolean(deviceData && deviceData.devices);
|
||||
this.devices = deviceData ? deviceData.devices : {},
|
||||
this.devices = deviceData ? deviceData.devices : {};
|
||||
this.crossSigningInfo = deviceData ?
|
||||
deviceData.crossSigningInfo || {} : {};
|
||||
this.deviceTrackingStatus = deviceData ?
|
||||
@@ -190,7 +190,7 @@ export class DeviceList extends TypedEventEmitter<EmittedEvents, CryptoEventHand
|
||||
|
||||
let savePromise = this.savePromise;
|
||||
if (savePromise === null) {
|
||||
savePromise = new Promise((resolve, reject) => {
|
||||
savePromise = new Promise((resolve) => {
|
||||
this.resolveSavePromise = resolve;
|
||||
});
|
||||
this.savePromise = savePromise;
|
||||
|
||||
@@ -271,9 +271,9 @@ export class SAS extends Base<SasEvent, EventHandlerMap> {
|
||||
do {
|
||||
try {
|
||||
if (this.initiatedByMe) {
|
||||
return this.doSendVerification();
|
||||
return await this.doSendVerification();
|
||||
} else {
|
||||
return this.doRespondVerification();
|
||||
return await this.doRespondVerification();
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof SwitchStartEventError) {
|
||||
|
||||
@@ -152,7 +152,7 @@ export interface ICryptoCallbacks {
|
||||
export function createClient(opts: ICreateClientOpts | string) {
|
||||
if (typeof opts === "string") {
|
||||
opts = {
|
||||
"baseUrl": opts as string,
|
||||
"baseUrl": opts,
|
||||
};
|
||||
}
|
||||
opts.request = opts.request || requestInstance;
|
||||
|
||||
@@ -28,7 +28,6 @@ import { EventType, RelationType } from "../@types/event";
|
||||
import { RoomState } from "./room-state";
|
||||
import { TypedEventEmitter } from "./typed-event-emitter";
|
||||
|
||||
// var DEBUG = false;
|
||||
const DEBUG = true;
|
||||
|
||||
let debuglog: (...args: any[]) => void;
|
||||
|
||||
@@ -26,10 +26,9 @@ import { MatrixEvent, MatrixEventEvent } from "./event";
|
||||
import { MatrixClient } from "../client";
|
||||
import { GuestAccess, HistoryVisibility, IJoinRuleEventContent, JoinRule } from "../@types/partials";
|
||||
import { TypedEventEmitter } from "./typed-event-emitter";
|
||||
import { Beacon, BeaconEvent, BeaconEventHandlerMap } from "./beacon";
|
||||
import { Beacon, BeaconEvent, BeaconEventHandlerMap, getBeaconInfoIdentifier, BeaconIdentifier } from "./beacon";
|
||||
import { TypedReEmitter } from "../ReEmitter";
|
||||
import { M_BEACON, M_BEACON_INFO } from "../@types/beacon";
|
||||
import { getBeaconInfoIdentifier, BeaconIdentifier } from "./beacon";
|
||||
|
||||
// possible statuses for out-of-band member loading
|
||||
enum OobStatus {
|
||||
|
||||
@@ -1124,14 +1124,14 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
|
||||
* The aliases returned by this function may not necessarily
|
||||
* still point to this room.
|
||||
* @return {array} The room's alias as an array of strings
|
||||
* @deprecated this uses m.room.aliases events, replaced by Room::getAltAliases()
|
||||
*/
|
||||
public getAliases(): string[] {
|
||||
const aliasStrings: string[] = [];
|
||||
|
||||
const aliasEvents = this.currentState.getStateEvents(EventType.RoomAliases);
|
||||
if (aliasEvents) {
|
||||
for (let i = 0; i < aliasEvents.length; ++i) {
|
||||
const aliasEvent = aliasEvents[i];
|
||||
for (const aliasEvent of aliasEvents) {
|
||||
if (Array.isArray(aliasEvent.getContent().aliases)) {
|
||||
const filteredAliases = aliasEvent.getContent<{ aliases: string[] }>().aliases.filter(a => {
|
||||
if (typeof(a) !== "string") return false;
|
||||
@@ -1141,7 +1141,7 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
|
||||
// It's probably valid by here.
|
||||
return true;
|
||||
});
|
||||
Array.prototype.push.apply(aliasStrings, filteredAliases);
|
||||
aliasStrings.push(...filteredAliases);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1644,8 +1644,8 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
|
||||
eventsByThread[threadId]?.push(event);
|
||||
}
|
||||
|
||||
Object.entries(eventsByThread).map(([threadId, events]) => (
|
||||
this.addThreadedEvents(threadId, events, toStartOfTimeline)
|
||||
Object.entries(eventsByThread).map(([threadId, threadEvents]) => (
|
||||
this.addThreadedEvents(threadId, threadEvents, toStartOfTimeline)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -2143,23 +2143,23 @@ export class Room extends TypedEventEmitter<EmittedEvents, RoomEventHandlerMap>
|
||||
const threadRoots = this.findThreadRoots(events);
|
||||
const eventsByThread: { [threadId: string]: MatrixEvent[] } = {};
|
||||
|
||||
for (let i = 0; i < events.length; i++) {
|
||||
for (const event of events) {
|
||||
// TODO: We should have a filter to say "only add state event types X Y Z to the timeline".
|
||||
this.processLiveEvent(events[i]);
|
||||
this.processLiveEvent(event);
|
||||
|
||||
const {
|
||||
shouldLiveInRoom,
|
||||
shouldLiveInThread,
|
||||
threadId,
|
||||
} = this.eventShouldLiveIn(events[i], events, threadRoots);
|
||||
} = this.eventShouldLiveIn(event, events, threadRoots);
|
||||
|
||||
if (shouldLiveInThread && !eventsByThread[threadId]) {
|
||||
eventsByThread[threadId] = [];
|
||||
}
|
||||
eventsByThread[threadId]?.push(events[i]);
|
||||
eventsByThread[threadId]?.push(event);
|
||||
|
||||
if (shouldLiveInRoom) {
|
||||
this.addLiveEvent(events[i], duplicateStrategy, fromCache);
|
||||
this.addLiveEvent(event, duplicateStrategy, fromCache);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export interface ISavedSync {
|
||||
export interface IStore {
|
||||
readonly accountData: Record<string, MatrixEvent>; // type : content
|
||||
|
||||
/** @return {Promise<bool>} whether or not the database was newly created in this session. */
|
||||
/** @return {Promise<boolean>} whether or not the database was newly created in this session. */
|
||||
isNewlyCreated(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,7 +123,7 @@ export class StubStore implements IStore {
|
||||
/**
|
||||
* No-op.
|
||||
* @param {Room} room
|
||||
* @param {integer} limit
|
||||
* @param {number} limit
|
||||
* @return {Array}
|
||||
*/
|
||||
public scrollback(room: Room, limit: number): MatrixEvent[] {
|
||||
|
||||
Reference in New Issue
Block a user