From 67a19e6c2b9abc43b643aa36b9f179001d90ec71 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Wed, 25 Apr 2018 03:19:45 +0800 Subject: [PATCH] update profile photo on select and/or save (#1614) --- .../profile_picture/profile_picture.js | 16 ++++++++++++---- app/screens/edit_profile/edit_profile.js | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/components/profile_picture/profile_picture.js b/app/components/profile_picture/profile_picture.js index a7b534721..c58da5435 100644 --- a/app/components/profile_picture/profile_picture.js +++ b/app/components/profile_picture/profile_picture.js @@ -22,7 +22,6 @@ const STATUS_BUFFER = Platform.select({ export default class ProfilePicture extends PureComponent { static propTypes = { size: PropTypes.number, - statusBorderWidth: PropTypes.number, statusSize: PropTypes.number, user: PropTypes.object, showStatus: PropTypes.bool, @@ -38,7 +37,6 @@ export default class ProfilePicture extends PureComponent { static defaultProps = { showStatus: true, size: 128, - statusBorderWidth: 2, statusSize: 14, edit: false, }; @@ -65,7 +63,13 @@ export default class ProfilePicture extends PureComponent { } componentWillUpdate(nextProps) { - if (Boolean(nextProps.user) !== Boolean(this.props.user) || nextProps.user.id !== this.props.user.id) { + if ( + Boolean(nextProps.user) !== Boolean(this.props.user) || + nextProps.user.id !== this.props.user.id || + nextProps.user.last_picture_update !== this.props.user.last_picture_update + ) { + this.setState({pictureUrl: null}); + const nextUser = nextProps.user; if (this.mounted) { @@ -76,6 +80,10 @@ export default class ProfilePicture extends PureComponent { ImageCacheManager.cache('', Client4.getProfilePictureUrl(nextUser.id, nextUser.last_picture_update), this.setImageURL); } } + + if (nextProps.edit && nextProps.imageUri !== this.props.imageUri) { + this.setImageURL(nextProps.imageUri); + } } componentWillUnmount() { @@ -121,7 +129,7 @@ export default class ProfilePicture extends PureComponent { let source = null; if (pictureUrl) { let prefix = ''; - if (Platform.OS === 'android') { + if (Platform.OS === 'android' && !pictureUrl.includes('content://')) { prefix = 'file://'; } diff --git a/app/screens/edit_profile/edit_profile.js b/app/screens/edit_profile/edit_profile.js index 0d99f4f45..5a494b586 100644 --- a/app/screens/edit_profile/edit_profile.js +++ b/app/screens/edit_profile/edit_profile.js @@ -11,7 +11,7 @@ import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view'; import Loading from 'app/components/loading'; import ErrorText from 'app/components/error_text'; import StatusBar from 'app/components/status_bar/index'; -import ProfilePicture from 'app/components/profile_picture/index'; +import ProfilePicture from 'app/components/profile_picture'; import AttachmentButton from 'app/components/attachment_button'; import {emptyFunction} from 'app/utils/general'; import {preventDoubleTap} from 'app/utils/tap';