diff --git a/src/client.ts b/src/client.ts index 45ced3946f9..220795e8b65 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1296,9 +1296,9 @@ export class MatrixClient extends TypedEventEmitter { + public async getDehydratedDevice(): Promise { try { - return this.http.authedRequest( + return await this.http.authedRequest( undefined, Method.Get, "/dehydrated_device", @@ -3365,7 +3365,7 @@ export class MatrixClient extends TypedEventEmitter(eventType: string): Promise { + public async getAccountDataFromServer(eventType: string): Promise { if (this.isInitialSyncComplete()) { const event = this.store.getAccountData(eventType); if (!event) { @@ -3380,11 +3380,9 @@ export class MatrixClient extends TypedEventEmitter = {}; // {roomId: Error} + const populationResults: { [roomId: string]: Error } = {}; const promises = []; const doLeave = (roomId: string) => { @@ -5875,7 +5873,7 @@ export class MatrixClient extends TypedEventEmitter | void { let promise: Promise; - 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 { // 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); diff --git a/src/crypto/DeviceList.ts b/src/crypto/DeviceList.ts index 5fdae5c245f..40c055c7b50 100644 --- a/src/crypto/DeviceList.ts +++ b/src/crypto/DeviceList.ts @@ -122,7 +122,7 @@ export class DeviceList extends TypedEventEmitter { 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 { + savePromise = new Promise((resolve) => { this.resolveSavePromise = resolve; }); this.savePromise = savePromise; diff --git a/src/crypto/verification/SAS.ts b/src/crypto/verification/SAS.ts index 93244464f66..a909ce7421b 100644 --- a/src/crypto/verification/SAS.ts +++ b/src/crypto/verification/SAS.ts @@ -271,9 +271,9 @@ export class SAS extends Base { 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) { diff --git a/src/matrix.ts b/src/matrix.ts index c85544e669e..e2ce5e11c9a 100644 --- a/src/matrix.ts +++ b/src/matrix.ts @@ -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; diff --git a/src/models/event-timeline-set.ts b/src/models/event-timeline-set.ts index d7396278132..aeb019112d0 100644 --- a/src/models/event-timeline-set.ts +++ b/src/models/event-timeline-set.ts @@ -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; diff --git a/src/models/room-state.ts b/src/models/room-state.ts index d6513389948..30b87f487b9 100644 --- a/src/models/room-state.ts +++ b/src/models/room-state.ts @@ -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 { diff --git a/src/models/room.ts b/src/models/room.ts index e0769097ecd..be185255397 100644 --- a/src/models/room.ts +++ b/src/models/room.ts @@ -1124,14 +1124,14 @@ export class Room extends TypedEventEmitter * 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 // 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 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 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); } } diff --git a/src/store/index.ts b/src/store/index.ts index 51d325c953f..c47bd20ad48 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -37,7 +37,7 @@ export interface ISavedSync { export interface IStore { readonly accountData: Record; // type : content - /** @return {Promise} whether or not the database was newly created in this session. */ + /** @return {Promise} whether or not the database was newly created in this session. */ isNewlyCreated(): Promise; /** diff --git a/src/store/stub.ts b/src/store/stub.ts index 47e1188a269..1b3a8773f4e 100644 --- a/src/store/stub.ts +++ b/src/store/stub.ts @@ -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[] {