Skip to content

Commit

Permalink
Add permalink to timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
andreistanciu24 committed Jan 27, 2017
1 parent d725474 commit f912957
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions webapp/components/post_view/components/post_info.jsx
Expand Up @@ -376,6 +376,7 @@ export default class PostInfo extends React.Component {
sameUser={this.props.sameUser}
compactDisplay={this.props.compactDisplay}
useMilitaryTime={this.props.useMilitaryTime}
postId={post.id}
/>
{flagTrigger}
</li>
Expand Down
26 changes: 23 additions & 3 deletions webapp/components/post_view/components/post_time.jsx
Expand Up @@ -6,13 +6,19 @@ import React from 'react';
import Constants from 'utils/constants.jsx';
import PureRenderMixin from 'react-addons-pure-render-mixin';

import {getDateForUnixTicks} from 'utils/utils.jsx';
import {getDateForUnixTicks, isMobile} from 'utils/utils.jsx';

import {Link} from 'react-router/es6';
import TeamStore from 'stores/team_store.jsx';

export default class PostTime extends React.Component {
constructor(props) {
super(props);

this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
this.state = {
currentTeamDisplayName: TeamStore.getCurrent().display_name
};
}

componentDidMount() {
Expand All @@ -25,13 +31,26 @@ export default class PostTime extends React.Component {
clearInterval(this.intervalId);
}

render() {
renderTimeTag() {
return (
<time className='post__time'>
{getDateForUnixTicks(this.props.eventTime).toLocaleString('en', {hour: '2-digit', minute: '2-digit', hour12: !this.props.useMilitaryTime})}
</time>
);
}

render() {
return isMobile() ?
this.renderTimeTag() :
(
<Link
to={`/${this.state.currentTeamDisplayName}/pl/${this.props.postId}`}
target='_blank'
>
{this.renderTimeTag()}
</Link>
);
}
}

PostTime.defaultProps = {
Expand All @@ -43,5 +62,6 @@ PostTime.propTypes = {
eventTime: React.PropTypes.number.isRequired,
sameUser: React.PropTypes.bool,
compactDisplay: React.PropTypes.bool,
useMilitaryTime: React.PropTypes.bool.isRequired
useMilitaryTime: React.PropTypes.bool.isRequired,
postId: React.PropTypes.string
};

0 comments on commit f912957

Please sign in to comment.