Show full date on search results (#934)

This commit is contained in:
enahum 2017-09-25 11:21:06 -03:00 committed by Harrison Healey
parent 98abbd6dca
commit e31d1834f6
3 changed files with 32 additions and 3 deletions

View file

@ -49,6 +49,7 @@ class Post extends PureComponent {
navigator: PropTypes.object,
roles: PropTypes.string,
shouldRenderReplyButton: PropTypes.bool,
showFullDate: PropTypes.bool,
tooltipVisible: PropTypes.bool,
theme: PropTypes.object.isRequired,
onPress: PropTypes.func,
@ -301,6 +302,7 @@ class Post extends PureComponent {
post,
renderReplies,
shouldRenderReplyButton,
showFullDate,
theme
} = this.props;
const style = getStyleSheet(theme);
@ -324,6 +326,7 @@ class Post extends PureComponent {
createAt={post.create_at}
isSearchResult={isSearchResult}
shouldRenderReplyButton={shouldRenderReplyButton}
showFullDate={showFullDate}
onPress={this.handleReply}
onViewUserProfile={this.viewUserProfile}
renderReplies={renderReplies}

View file

@ -11,6 +11,7 @@ import {
import FormattedText from 'app/components/formatted_text';
import FormattedTime from 'app/components/formatted_time';
import FormattedDate from 'app/components/formatted_date';
import ReplyIcon from 'app/components/reply_icon';
import {emptyFunction} from 'app/utils/general';
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
@ -33,6 +34,7 @@ export default class PostHeader extends PureComponent {
onViewUserProfile: PropTypes.func,
overrideUsername: PropTypes.string,
renderReplies: PropTypes.bool,
showFullDate: PropTypes.bool,
theme: PropTypes.object.isRequired
};
@ -143,20 +145,39 @@ export default class PostHeader extends PureComponent {
onPress,
renderReplies,
shouldRenderReplyButton,
showFullDate,
theme
} = this.props;
const style = getStyleSheet(theme);
const showReply = shouldRenderReplyButton || (!commentedOnDisplayName && commentCount > 0 && renderReplies);
let dateComponent;
if (showFullDate) {
dateComponent = (
<View style={style.datetime}>
<Text style={style.time}>
<FormattedDate value={createAt}/>
</Text>
<Text style={style.time}>
<FormattedTime value={createAt}/>
</Text>
</View>
);
} else {
dateComponent = (
<Text style={style.time}>
<FormattedTime value={createAt}/>
</Text>
);
}
return (
<View>
<View style={[style.postInfoContainer, (isPendingOrFailedPost && style.pendingPost)]}>
<View style={{flexDirection: 'row', flex: 1}}>
{this.getDisplayName(style)}
<View style={style.timeContainer}>
<Text style={style.time}>
<FormattedTime value={createAt}/>
</Text>
{dateComponent}
</View>
</View>
{showReply &&
@ -203,6 +224,10 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => {
timeContainer: {
justifyContent: 'center'
},
datetime: {
flex: 1,
flexDirection: 'row'
},
time: {
color: theme.centerChannelColor,
fontSize: 13,

View file

@ -301,6 +301,7 @@ class Search extends Component {
onReply={this.goToThread}
isSearchResult={true}
shouldRenderReplyButton={true}
showFullDate={true}
navigator={this.props.navigator}
/>
{separator}