Fixed null pointer in ProfilePicture (#1595)
This commit is contained in:
parent
1e79923e95
commit
5a23129a50
1 changed files with 13 additions and 1 deletions
|
|
@ -52,7 +52,7 @@ export default class ProfilePicture extends PureComponent {
|
|||
|
||||
if (edit && imageUri) {
|
||||
this.setImageURL(imageUri);
|
||||
} else {
|
||||
} else if (user) {
|
||||
ImageCacheManager.cache('', Client4.getProfilePictureUrl(user.id, user.last_picture_update), this.setImageURL);
|
||||
}
|
||||
}
|
||||
|
|
@ -63,6 +63,18 @@ export default class ProfilePicture extends PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
componentWillUpdate(nextProps) {
|
||||
if (Boolean(nextProps.user) !== Boolean(this.props.user) || nextProps.user.id !== this.props.user.id) {
|
||||
this.setState({pictureUrl: null});
|
||||
|
||||
const nextUser = nextProps.user;
|
||||
|
||||
if (nextUser) {
|
||||
ImageCacheManager.cache('', Client4.getProfilePictureUrl(nextUser.id, nextUser.last_picture_update), this.setImageURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setImageURL = (pictureUrl) => {
|
||||
this.setState({pictureUrl});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue