fixed reblog title after upvode

This commit is contained in:
u-e 2019-01-06 20:55:55 +03:00
parent 0521505910
commit 20666fd131

View File

@ -18,10 +18,19 @@ const DEFAULT_IMAGE = require('../../../../assets/esteem.png');
class PostHeaderDescription extends PureComponent { class PostHeaderDescription extends PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {}; this.state = {
reblogedBy: props.reblogedBy || null,
};
} }
// Component Life Cycles // Component Life Cycles
componentWillReceiveProps(nextProps) {
const { reblogedBy } = this.props;
if (reblogedBy !== nextProps.reblogedBy && !nextProps.reblogedBy) {
this.setState({ reblogedBy });
}
}
// Component Functions // Component Functions
_handleOnUserPress = (username) => { _handleOnUserPress = (username) => {
@ -43,16 +52,9 @@ class PostHeaderDescription extends PureComponent {
render() { render() {
const { const {
avatar, avatar, date, isHideImage, name, reputation, size, tag, tagOnPress,
date,
isHideImage,
name,
reblogedBy,
reputation,
size,
tag,
tagOnPress,
} = this.props; } = this.props;
const { reblogedBy } = this.state;
const _reputationText = `(${reputation})`; const _reputationText = `(${reputation})`;
let _avatar; let _avatar;
@ -85,7 +87,9 @@ class PostHeaderDescription extends PureComponent {
</TouchableOpacity> </TouchableOpacity>
)} )}
<Text style={styles.date}>{date}</Text> <Text style={styles.date}>{date}</Text>
{!!reblogedBy && <TextWithIcon text={reblogedBy} iconType="MaterialIcons" iconName="repeat" />} {!!reblogedBy && (
<TextWithIcon text={reblogedBy} iconType="MaterialIcons" iconName="repeat" />
)}
</View> </View>
); );
} }