Remove deprecated lifecycle methods from misc components (#3426)

* Remove deprecated lifecycle methods from misc components

* Fixed linting errors
This commit is contained in:
Romain FOYARD 2019-10-22 02:20:58 +02:00 committed by Elias Nahum
parent e69b7c46ba
commit b910786002
3 changed files with 23 additions and 27 deletions

View file

@ -67,27 +67,6 @@ export default class ProfilePicture extends PureComponent {
}
}
componentWillReceiveProps(nextProps) {
if (this.mounted) {
if (nextProps.edit && nextProps.imageUri && nextProps.imageUri !== this.props.imageUri) {
this.setImageURL(nextProps.imageUri);
return;
}
if (nextProps.profileImageUri !== '' && nextProps.profileImageUri !== this.props.profileImageUri) {
this.setImageURL(nextProps.profileImageUri);
}
const url = this.props.user ? Client4.getProfilePictureUrl(this.props.user.id, this.props.user.last_picture_update) : null;
const nextUrl = nextProps.user ? Client4.getProfilePictureUrl(nextProps.user.id, nextProps.user.last_picture_update) : null;
if (nextUrl && url !== nextUrl) {
// empty function is so that promise unhandled is not triggered in dev mode
ImageCacheManager.cache('', nextUrl, this.setImageURL).then(this.clearProfileImageUri).catch(emptyFunction);
}
}
}
componentWillUnmount() {
this.mounted = false;
}
@ -107,6 +86,23 @@ export default class ProfilePicture extends PureComponent {
componentDidUpdate(prevProps) {
if (this.props.profileImageRemove !== prevProps.profileImageRemove) {
this.setImageURL(null);
} else if (this.mounted) {
if (this.props.edit && this.props.imageUri && this.props.imageUri !== prevProps.imageUri) {
this.setImageURL(this.props.imageUri);
return;
}
if (this.props.profileImageUri !== '' && this.props.profileImageUri !== prevProps.profileImageUri) {
this.setImageURL(this.props.profileImageUri);
}
const url = prevProps.user ? Client4.getProfilePictureUrl(prevProps.user.id, prevProps.user.last_picture_update) : null;
const nextUrl = this.props.user ? Client4.getProfilePictureUrl(this.props.user.id, this.props.user.last_picture_update) : null;
if (nextUrl && url !== nextUrl) {
// empty function is so that promise unhandled is not triggered in dev mode
ImageCacheManager.cache('', nextUrl, this.setImageURL).then(this.clearProfileImageUri).catch(emptyFunction);
}
}
}

View file

@ -19,9 +19,9 @@ export default class RetryBarIndicator extends PureComponent {
retryMessageHeight: new Animated.Value(0),
};
componentWillReceiveProps(nextProps) {
if (this.props.failed !== nextProps.failed) {
this.toggleRetryMessage(nextProps.failed);
componentDidUpdate(prevProps) {
if (this.props.failed !== prevProps.failed) {
this.toggleRetryMessage(this.props.failed);
}
}

View file

@ -132,9 +132,9 @@ export default class Search extends Component {
this.shadowHeight = this.props.shadowOffsetHeightCollapsed;
}
componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
if (nextProps.value) {
componentDidUpdate(prevProps) {
if (this.props.value !== prevProps.value) {
if (this.props.value) {
this.iconDeleteAnimated = new Animated.Value(1);
} else {
this.iconDeleteAnimated = new Animated.Value(0);