Fix accessing room prop which is optional (#9523)

Co-authored-by: Michael Weimann <michaelw@matrix.org>
This commit is contained in:
Michael Telatynski 2023-01-11 18:21:11 +00:00 committed by GitHub
parent 575508ae15
commit f58d62d339
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -498,9 +498,10 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
} }
const myUserId = MatrixClientPeg.get().getUserId(); const myUserId = MatrixClientPeg.get().getUserId();
const memberEventContent = this.props.room.currentState.getMember(myUserId).events.member.getContent(); const member = this.props.room?.currentState.getMember(myUserId);
const memberEventContent = member?.events.member?.getContent();
if (memberEventContent.reason) { if (memberEventContent?.reason) {
reasonElement = ( reasonElement = (
<InviteReason <InviteReason
reason={memberEventContent.reason} reason={memberEventContent.reason}