Use MatrixClientPeg::safeGet for strict typing (#10989)

This commit is contained in:
Michael Telatynski 2023-06-21 17:29:44 +01:00 committed by GitHub
parent d64018ce26
commit 9b5b053148
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 225 additions and 203 deletions

View file

@ -149,7 +149,7 @@ export class CapabilityText {
return { primary: _t("The above, but in any room you are joined or invited to as well") };
} else {
const roomId = getTimelineRoomIDFromCapability(capability);
const room = MatrixClientPeg.get().getRoom(roomId);
const room = MatrixClientPeg.safeGet().getRoom(roomId);
return {
primary: _t(
"The above, but in <Room /> as well",

View file

@ -62,7 +62,7 @@ export class Jitsi {
}
public start(): void {
const cli = MatrixClientPeg.get();
const cli = MatrixClientPeg.safeGet();
cli.on(ClientEvent.ClientWellKnown, this.update);
// call update initially in case we missed the first WellKnown.client event and for if no well-known present
this.update(cli.getClientWellKnown());

View file

@ -43,7 +43,7 @@ function getWidgetBuildUrl(roomId: string): string | undefined {
return SdkConfig.get().widget_build_url;
}
const wellKnown = getCallBehaviourWellKnown(MatrixClientPeg.get());
const wellKnown = getCallBehaviourWellKnown(MatrixClientPeg.safeGet());
if (isDm && wellKnown?.ignore_dm) {
return undefined;
}
@ -56,7 +56,7 @@ export function isManagedHybridWidgetEnabled(roomId: string): boolean {
}
export async function addManagedHybridWidget(roomId: string): Promise<void> {
const cli = MatrixClientPeg.get();
const cli = MatrixClientPeg.safeGet();
const room = cli.getRoom(roomId);
if (!room) {
return;