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
Typescript fixes due to MatrixEvent being TSified
This commit is contained in:
@@ -21,7 +21,7 @@ limitations under the License.
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
import { SyncApi } from "./sync";
|
||||
import { EventStatus, MatrixEvent } from "./models/event";
|
||||
import { EventStatus, IDecryptOptions, MatrixEvent } from "./models/event";
|
||||
import { StubStore } from "./store/stub";
|
||||
import { createNewMatrixCall, MatrixCall } from "./webrtc/call";
|
||||
import { Filter } from "./filter";
|
||||
@@ -3042,7 +3042,7 @@ export class MatrixClient extends EventEmitter {
|
||||
if (event && event.getType() === "m.room.power_levels") {
|
||||
// take a copy of the content to ensure we don't corrupt
|
||||
// existing client state with a failed power level change
|
||||
content = utils.deepCopy(event.getContent());
|
||||
content = utils.deepCopy(event.getContent()) as typeof content;
|
||||
}
|
||||
content.users[userId] = powerLevel;
|
||||
const path = utils.encodeUri("/rooms/$roomId/state/m.room.power_levels", {
|
||||
@@ -5707,13 +5707,13 @@ export class MatrixClient extends EventEmitter {
|
||||
* @param {boolean} options.isRetry True if this is a retry (enables more logging)
|
||||
* @param {boolean} options.emit Emits "event.decrypted" if set to true
|
||||
*/
|
||||
public decryptEventIfNeeded(event: MatrixEvent, options?: { emit: boolean, isRetry: boolean }): Promise<void> {
|
||||
public decryptEventIfNeeded(event: MatrixEvent, options?: IDecryptOptions): Promise<void> {
|
||||
if (event.shouldAttemptDecryption()) {
|
||||
event.attemptDecryption(this.crypto, options);
|
||||
}
|
||||
|
||||
if (event.isBeingDecrypted()) {
|
||||
return event._decryptionPromise;
|
||||
return event.getDecryptionPromise();
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -319,8 +319,7 @@ export class Relations extends EventEmitter {
|
||||
|
||||
// the all-knowning server tells us that the event at some point had
|
||||
// this timestamp for its replacement, so any following replacement should definitely not be less
|
||||
const replaceRelation =
|
||||
this.targetEvent.getServerAggregatedRelation(RelationType.Replace);
|
||||
const replaceRelation = this.targetEvent.getServerAggregatedRelation(RelationType.Replace);
|
||||
const minTs = replaceRelation && replaceRelation.origin_server_ts;
|
||||
|
||||
const lastReplacement = this.getRelations().reduce((last, event) => {
|
||||
@@ -339,7 +338,7 @@ export class Relations extends EventEmitter {
|
||||
if (lastReplacement?.shouldAttemptDecryption()) {
|
||||
await lastReplacement.attemptDecryption(this.room._client.crypto);
|
||||
} else if (lastReplacement?.isBeingDecrypted()) {
|
||||
await lastReplacement._decryptionPromise;
|
||||
await lastReplacement.getDecryptionPromise();
|
||||
}
|
||||
|
||||
return lastReplacement;
|
||||
|
||||
@@ -59,7 +59,7 @@ export class MemoryStore implements IStore {
|
||||
// filterId: Filter
|
||||
// }
|
||||
private filters: Record<string, Record<string, Filter>> = {};
|
||||
private accountData: Record<string, object> = {}; // type : content
|
||||
private accountData: Record<string, MatrixEvent> = {}; // type : content
|
||||
private readonly localStorage: Storage;
|
||||
private oobMembers: Record<string, MatrixEvent[]> = {}; // roomId: [member events]
|
||||
private clientOptions = {};
|
||||
@@ -330,7 +330,7 @@ export class MemoryStore implements IStore {
|
||||
* @param {string} eventType The event type being queried
|
||||
* @return {?MatrixEvent} the user account_data event of given type, if any
|
||||
*/
|
||||
public getAccountData(eventType: EventType | string): MatrixEvent | null {
|
||||
public getAccountData(eventType: EventType | string): MatrixEvent | undefined {
|
||||
return this.accountData[eventType];
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,9 @@ export class StubStore implements IStore {
|
||||
* Get account data event by event type
|
||||
* @param {string} eventType The event type being queried
|
||||
*/
|
||||
public getAccountData(eventType: EventType | string): MatrixEvent {}
|
||||
public getAccountData(eventType: EventType | string): MatrixEvent | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* setSyncData does nothing as there is no backing data store.
|
||||
|
||||
@@ -24,7 +24,7 @@ limitations under the License.
|
||||
import { logger } from '../logger';
|
||||
import { EventEmitter } from 'events';
|
||||
import * as utils from '../utils';
|
||||
import MatrixEvent from '../models/event';
|
||||
import { MatrixEvent } from '../models/event';
|
||||
import { EventType } from '../@types/event';
|
||||
import { RoomMember } from '../models/room-member';
|
||||
import { randomString } from '../randomstring';
|
||||
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import MatrixEvent from '../models/event';
|
||||
import { MatrixEvent } from '../models/event';
|
||||
import { logger } from '../logger';
|
||||
import { createNewMatrixCall, MatrixCall, CallErrorCode, CallState, CallDirection } from './call';
|
||||
import { EventType } from '../@types/event';
|
||||
@@ -244,7 +244,7 @@ export class CallEventHandler {
|
||||
} else {
|
||||
call.onRemoteIceCandidatesReceived(event);
|
||||
}
|
||||
} else if ([EventType.CallHangup, EventType.CallReject].includes(event.getType())) {
|
||||
} else if ([EventType.CallHangup, EventType.CallReject].includes(event.getType() as EventType)) {
|
||||
// Note that we also observe our own hangups here so we can see
|
||||
// if we've already rejected a call that would otherwise be valid
|
||||
if (!call) {
|
||||
|
||||
Reference in New Issue
Block a user