Use MatrixClientPeg::safeGet in src/{stores,hooks,components/structures}/* (#10988)

This commit is contained in:
Michael Telatynski 2023-06-15 15:11:49 +01:00 committed by GitHub
parent 707fd9ccf0
commit dd46db4817
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 139 additions and 130 deletions

View file

@ -291,7 +291,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
if (!this.state.contextMenuPosition) return null;
let topSection: JSX.Element | undefined;
if (MatrixClientPeg.get().isGuest()) {
if (MatrixClientPeg.safeGet().isGuest()) {
topSection = (
<div className="mx_UserMenu_contextMenu_header mx_UserMenu_contextMenu_guestPrompts">
{_t(
@ -372,7 +372,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
</IconizedContextMenuOptionList>
);
if (MatrixClientPeg.get().isGuest()) {
if (MatrixClientPeg.safeGet().isGuest()) {
primaryOptionList = (
<IconizedContextMenuOptionList>
{homeButton}
@ -399,7 +399,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
</span>
<span className="mx_UserMenu_contextMenu_userId">
{UserIdentifierCustomisations.getDisplayUserIdentifier(
MatrixClientPeg.get().getSafeUserId(),
MatrixClientPeg.safeGet().getSafeUserId(),
{
withDisplayName: true,
},
@ -428,7 +428,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
public render(): React.ReactNode {
const avatarSize = 32; // should match border-radius of the avatar
const userId = MatrixClientPeg.get().getSafeUserId();
const userId = MatrixClientPeg.safeGet().getSafeUserId();
const displayName = OwnProfileStore.instance.displayName || userId;
const avatarUrl = OwnProfileStore.instance.getHttpAvatarUrl(avatarSize);