Skip to content

Commit

Permalink
Merge pull request #2816 from matrix-org/dbkr/groupcall_more_strict
Browse files Browse the repository at this point in the history
A few more strict mode fixes
  • Loading branch information
dbkr authored Oct 27, 2022
2 parents 13c751c + d979302 commit 77ef855
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* have been processed.
*/
public waitUntilRoomReadyForGroupCalls(roomId: string): Promise<void> {
return this.groupCallEventHandler.waitUntilRoomReadyForGroupCalls(roomId);
return this.groupCallEventHandler!.waitUntilRoomReadyForGroupCalls(roomId);
}

/**
Expand All @@ -1616,7 +1616,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @returns {GroupCall} The group call or null if it doesn't already exist.
*/
public getGroupCallForRoom(roomId: string): GroupCall | null {
return this.groupCallEventHandler.groupCalls.get(roomId) || null;
return this.groupCallEventHandler!.groupCalls.get(roomId) || null;
}

/**
Expand Down Expand Up @@ -6397,8 +6397,8 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa

private startCallEventHandler = (): void => {
if (this.isInitialSyncComplete()) {
this.callEventHandler.start();
this.groupCallEventHandler.start();
this.callEventHandler!.start();
this.groupCallEventHandler!.start();
this.off(ClientEvent.Sync, this.startCallEventHandler);
}
};
Expand Down
18 changes: 9 additions & 9 deletions src/embedded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export interface ICapabilities {
* @experimental This class is considered unstable!
*/
export class RoomWidgetClient extends MatrixClient {
private room: Room;
private room?: Room;
private widgetApiReady = new Promise<void>(resolve => this.widgetApi.once("ready", resolve));
private lifecycle: AbortController;
private lifecycle?: AbortController;
private syncState: SyncState | null = null;

constructor(
Expand Down Expand Up @@ -197,7 +197,7 @@ export class RoomWidgetClient extends MatrixClient {
const rawEvents = await this.widgetApi.readStateEvents(eventType, undefined, stateKey, [this.roomId]);
const events = rawEvents.map(rawEvent => new MatrixEvent(rawEvent as Partial<IEvent>));

await this.syncApi.injectRoomEvents(this.room, [], events);
await this.syncApi!.injectRoomEvents(this.room!, [], events);
events.forEach(event => {
this.emit(ClientEvent.Event, event);
logger.info(`Backfilled event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);
Expand All @@ -216,11 +216,11 @@ export class RoomWidgetClient extends MatrixClient {
this.widgetApi.off(`action:${WidgetApiToWidgetAction.SendToDevice}`, this.onToDevice);

super.stopClient();
this.lifecycle.abort(); // Signal to other async tasks that the client has stopped
this.lifecycle!.abort(); // Signal to other async tasks that the client has stopped
}

public async joinRoom(roomIdOrAlias: string): Promise<Room> {
if (roomIdOrAlias === this.roomId) return this.room;
if (roomIdOrAlias === this.roomId) return this.room!;
throw new Error(`Unknown room: ${roomIdOrAlias}`);
}

Expand Down Expand Up @@ -284,7 +284,7 @@ export class RoomWidgetClient extends MatrixClient {
}

// Overridden since we 'sync' manually without the sync API
public getSyncState(): SyncState {
public getSyncState(): SyncState | null {
return this.syncState;
}

Expand All @@ -305,7 +305,7 @@ export class RoomWidgetClient extends MatrixClient {
// send us events from other rooms if this widget is always on screen
if (ev.detail.data.room_id === this.roomId) {
const event = new MatrixEvent(ev.detail.data as Partial<IEvent>);
await this.syncApi.injectRoomEvents(this.room, [], [event]);
await this.syncApi!.injectRoomEvents(this.room!, [], [event]);
this.emit(ClientEvent.Event, event);
this.setSyncState(SyncState.Syncing);
logger.info(`Received event ${event.getId()} ${event.getType()} ${event.getStateKey()}`);
Expand Down Expand Up @@ -336,7 +336,7 @@ export class RoomWidgetClient extends MatrixClient {
private async watchTurnServers() {
const servers = this.widgetApi.getTurnServers();
const onClientStopped = () => servers.return(undefined);
this.lifecycle.signal.addEventListener("abort", onClientStopped);
this.lifecycle!.signal.addEventListener("abort", onClientStopped);

try {
for await (const server of servers) {
Expand All @@ -351,7 +351,7 @@ export class RoomWidgetClient extends MatrixClient {
} catch (e) {
logger.warn("Error watching TURN servers", e);
} finally {
this.lifecycle.signal.removeEventListener("abort", onClientStopped);
this.lifecycle!.signal.removeEventListener("abort", onClientStopped);
}
}
}

0 comments on commit 77ef855

Please sign in to comment.