Skip to content

Commit

Permalink
Merge cfff9ba into 187aff9
Browse files Browse the repository at this point in the history
  • Loading branch information
andreistanciu24 committed Feb 1, 2017
2 parents 187aff9 + cfff9ba commit 09deea4
Show file tree
Hide file tree
Showing 3 changed files with 40 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
35 changes: 32 additions & 3 deletions webapp/components/post_view/components/post_time.jsx
Expand Up @@ -6,26 +6,40 @@ 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().name,
width: '',
height: ''
};
}

componentDidMount() {
this.intervalId = setInterval(() => {
this.forceUpdate();
}, Constants.TIME_SINCE_UPDATE_INTERVAL);
window.addEventListener('resize', this.updateDimensions.bind(this));
}

componentWillUnmount() {
clearInterval(this.intervalId);
window.removeEventListener('resize', this.updateDimensions.bind(this));
}

render() {
updateDimensions() {
this.setState({width: window.innerWidth, height: window.innerHeight});
}

renderTimeTag() {
return (
<time
className='post__time'
Expand All @@ -35,6 +49,20 @@ export default class PostTime extends React.Component {
</time>
);
}

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

PostTime.defaultProps = {
Expand All @@ -46,5 +74,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
};
7 changes: 7 additions & 0 deletions webapp/sass/layout/_post.scss
Expand Up @@ -1195,6 +1195,13 @@
font-size: .9em;
}

.post__permalink {
color: #333;
&:hover {
color: #333;
}
}

.post-loading-gif {
height: 10px;
margin-top: 6px;
Expand Down

0 comments on commit 09deea4

Please sign in to comment.