diff --git a/app/components/profile_picture/profile_picture.js b/app/components/profile_picture/profile_picture.js index 8816748fb..3c6f5adb5 100644 --- a/app/components/profile_picture/profile_picture.js +++ b/app/components/profile_picture/profile_picture.js @@ -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}); };