From 145842e19eb2264dd33db6a35b86d0697a78153c Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 7 Feb 2019 09:20:43 -0300 Subject: [PATCH] Fix placeholder image on Android when profile pic is removed (#2551) --- .../profile_picture/profile_picture.js | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/app/components/profile_picture/profile_picture.js b/app/components/profile_picture/profile_picture.js index 46ba37496..a079c89da 100644 --- a/app/components/profile_picture/profile_picture.js +++ b/app/components/profile_picture/profile_picture.js @@ -48,7 +48,6 @@ export default class ProfilePicture extends PureComponent { state = { pictureUrl: null, - otherImageProps: {}, }; componentDidMount() { @@ -99,34 +98,21 @@ export default class ProfilePicture extends PureComponent { } }; - showDefaultImage = () => { - if (this.mounted) { - this.setState({otherImageProps: {defaultSource: placeholder}}); - } - }; - clearProfileImageUri = () => { if (this.props.isCurrentUser && this.props.profileImageUri !== '') { this.props.actions.setProfileImageUri(''); } } - componentDidUpdate(prevProps, prevState) { - if (!this.props.edit) { - if (this.state.otherImageProps !== prevState.otherImageProps) { - this.showDefaultImage(); - } - } - + componentDidUpdate(prevProps) { if (this.props.profileImageRemove !== prevProps.profileImageRemove) { this.setImageURL(null); - this.showDefaultImage(); } } render() { const {edit, showStatus, theme} = this.props; - const {pictureUrl, otherImageProps} = this.state; + const {pictureUrl} = this.state; const style = getStyleSheet(theme); let statusIcon; @@ -155,6 +141,7 @@ export default class ProfilePicture extends PureComponent { } let source = null; + let image; if (pictureUrl) { let prefix = ''; if (Platform.OS === 'android' && !pictureUrl.startsWith('content://') && @@ -165,16 +152,26 @@ export default class ProfilePicture extends PureComponent { source = { uri: `${prefix}${pictureUrl}`, }; - } - return ( - + image = ( + ); + } else { + image = ( + + ); + } + + return ( + + {image} {(showStatus || edit) && {statusIcon}