diff --git a/app/components/profile_picture/profile_picture.js b/app/components/profile_picture/profile_picture.js index 61a20bcbc..82f6b63d5 100644 --- a/app/components/profile_picture/profile_picture.js +++ b/app/components/profile_picture/profile_picture.js @@ -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); + } } } diff --git a/app/components/retry_bar_indicator/retry_bar_indicator.js b/app/components/retry_bar_indicator/retry_bar_indicator.js index 0cb943b55..c812cb5e1 100644 --- a/app/components/retry_bar_indicator/retry_bar_indicator.js +++ b/app/components/retry_bar_indicator/retry_bar_indicator.js @@ -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); } } diff --git a/app/components/search_bar/search_box.js b/app/components/search_bar/search_box.js index dbf390bfb..1f2f12180 100644 --- a/app/components/search_bar/search_box.js +++ b/app/components/search_bar/search_box.js @@ -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);