Use MatrixClientPeg::safeGet in src/components/views/* (#10987)

This commit is contained in:
Michael Telatynski 2023-06-15 08:46:19 +01:00 committed by GitHub
parent 4243847f4f
commit 280f6a9d93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 265 additions and 250 deletions

View file

@ -73,7 +73,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
public componentDidMount(): void {
this.dispatcherRef = dis.register(this.onAction);
MatrixClientPeg.get().on(RoomEvent.Name, this.onRoomName);
MatrixClientPeg.safeGet().on(RoomEvent.Name, this.onRoomName);
this.onRoomName();
}
@ -89,7 +89,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
dis.unregister(this.dispatcherRef);
}
MatrixClientPeg.get().removeListener(RoomEvent.Name, this.onRoomName);
MatrixClientPeg.get()?.removeListener(RoomEvent.Name, this.onRoomName);
}
/**
@ -98,7 +98,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
* @throws when room is not found
*/
private getRoom(): Room {
const room = MatrixClientPeg.get().getRoom(this.props.roomId)!;
const room = MatrixClientPeg.safeGet().getRoom(this.props.roomId)!;
// something is really wrong if we encounter this
if (!room) {