update profile photo on select and/or save (#1614)
This commit is contained in:
parent
223bd40703
commit
67a19e6c2b
2 changed files with 13 additions and 5 deletions
|
|
@ -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://';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Reference in a new issue