diff --git a/app/components/profile_picture/profile_picture.js b/app/components/profile_picture/profile_picture.js index c58da5435..869a816c6 100644 --- a/app/components/profile_picture/profile_picture.js +++ b/app/components/profile_picture/profile_picture.js @@ -10,6 +10,7 @@ import {Client4} from 'mattermost-redux/client'; import UserStatus from 'app/components/user_status'; import ImageCacheManager from 'app/utils/image_cache_manager'; +import {emptyFunction} from 'app/utils/general'; import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; import placeholder from 'assets/images/profile.jpg'; @@ -63,27 +64,25 @@ export default class ProfilePicture extends PureComponent { } componentWillUpdate(nextProps) { - 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}); + if (this.mounted) { + const url = this.state.pictureUrl; + const nextUrl = nextProps.user ? Client4.getProfilePictureUrl(nextProps.user.id, nextProps.user.last_picture_update) : null; - const nextUser = nextProps.user; + if (url !== nextUrl) { + this.setState({ + pictureUrl: nextUrl, + }); - if (this.mounted) { - this.setState({pictureUrl: null}); + if (nextUrl) { + // empty function is so that promise unhandled is not triggered in dev mode + ImageCacheManager.cache('', nextUrl, this.setImageUrl).then(emptyFunction).catch(emptyFunction); + } } - if (nextUser) { - ImageCacheManager.cache('', Client4.getProfilePictureUrl(nextUser.id, nextUser.last_picture_update), this.setImageURL); + if (nextProps.edit && nextProps.imageUri !== this.props.imageUri) { + this.setImageURL(nextProps.imageUri); } } - - if (nextProps.edit && nextProps.imageUri !== this.props.imageUri) { - this.setImageURL(nextProps.imageUri); - } } componentWillUnmount() { diff --git a/app/screens/code/code.js b/app/screens/code/code.js index 3a98bd048..d4c73bc6e 100644 --- a/app/screens/code/code.js +++ b/app/screens/code/code.js @@ -8,7 +8,6 @@ import { ScrollView, StyleSheet, Text, - TextInput, View, } from 'react-native'; @@ -50,27 +49,6 @@ export default class Code extends React.PureComponent { lineNumbersStyle = style.lineNumbers; } - let textComponent; - if (Platform.OS === 'ios') { - textComponent = ( - - ); - } else { - textComponent = ( - - {this.props.content} - - ); - } - return ( - {textComponent} + + {this.props.content} + ); @@ -131,9 +114,6 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => { android: { paddingVertical: 4, }, - ios: { - top: -4, - }, }), }, codeText: { diff --git a/app/screens/text_preview/text_preview.js b/app/screens/text_preview/text_preview.js index 5a662574d..a74d67da7 100644 --- a/app/screens/text_preview/text_preview.js +++ b/app/screens/text_preview/text_preview.js @@ -8,7 +8,6 @@ import { ScrollView, StyleSheet, Text, - TextInput, View, } from 'react-native'; @@ -50,27 +49,6 @@ export default class TextPreview extends React.PureComponent { lineNumbersStyle = style.lineNumbers; } - let textComponent; - if (Platform.OS === 'ios') { - textComponent = ( - - ); - } else { - textComponent = ( - - {this.props.content} - - ); - } - return ( - {textComponent} + + {this.props.content} + ); @@ -132,9 +115,6 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => { android: { paddingVertical: 4, }, - ios: { - top: -4, - }, }), }, codeText: {