mirror of
https://github.com/vector-im/element-web.git
synced 2025-08-23 07:21:22 +02:00
Fix MemberAvatar crash from EventTilePreview
This commit is contained in:
parent
125aef24b9
commit
af9f17219b
@ -64,7 +64,7 @@ export default class MemberAvatar extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static getState(props: IProps): IState {
|
private static getState(props: IProps): IState {
|
||||||
if (props.member && props.member.name) {
|
if (props.member?.name) {
|
||||||
let imageUrl = null;
|
let imageUrl = null;
|
||||||
if (props.member.getMxcAvatarUrl()) {
|
if (props.member.getMxcAvatarUrl()) {
|
||||||
imageUrl = mediaFromMxc(props.member.getMxcAvatarUrl()).getThumbnailOfSourceHttp(
|
imageUrl = mediaFromMxc(props.member.getMxcAvatarUrl()).getThumbnailOfSourceHttp(
|
||||||
|
@ -70,9 +70,7 @@ export default class EventTilePreview extends React.Component<IProps, IState> {
|
|||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
const userId = client.getUserId();
|
const userId = client.getUserId();
|
||||||
const profileInfo = await client.getProfileInfo(userId);
|
const profileInfo = await client.getProfileInfo(userId);
|
||||||
const avatarUrl = Avatar.avatarUrlForUser(
|
const avatarUrl = profileInfo.avatar_url;
|
||||||
{avatarUrl: profileInfo.avatar_url},
|
|
||||||
AVATAR_SIZE, AVATAR_SIZE, "crop");
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
userId,
|
userId,
|
||||||
@ -113,8 +111,9 @@ export default class EventTilePreview extends React.Component<IProps, IState> {
|
|||||||
name: displayname,
|
name: displayname,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
getAvatarUrl: (..._) => {
|
getAvatarUrl: (..._) => {
|
||||||
return avatarUrl;
|
return Avatar.avatarUrlForUser({avatarUrl}, AVATAR_SIZE, AVATAR_SIZE, "crop");
|
||||||
},
|
},
|
||||||
|
getMxcAvatarUrl: () => avatarUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user