diff options
Diffstat (limited to 'webapp/components/search_results_item.jsx')
-rw-r--r-- | webapp/components/search_results_item.jsx | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/webapp/components/search_results_item.jsx b/webapp/components/search_results_item.jsx index f0096a324..f2bca109a 100644 --- a/webapp/components/search_results_item.jsx +++ b/webapp/components/search_results_item.jsx @@ -22,7 +22,7 @@ const ActionTypes = Constants.ActionTypes; import React from 'react'; import {FormattedMessage, FormattedDate} from 'react-intl'; -import {browserHistory} from 'react-router/es6'; +import {browserHistory, Link} from 'react-router/es6'; export default class SearchResultsItem extends React.Component { constructor(props) { @@ -32,6 +32,24 @@ export default class SearchResultsItem extends React.Component { this.shrinkSidebar = this.shrinkSidebar.bind(this); this.unflagPost = this.unflagPost.bind(this); this.flagPost = this.flagPost.bind(this); + + this.state = { + currentTeamDisplayName: TeamStore.getCurrent().name, + width: '', + height: '' + }; + } + + componentDidMount() { + window.addEventListener('resize', () => { + Utils.updateWindowDimensions(this); + }); + } + + componentWillUnmount() { + window.removeEventListener('resize', () => { + Utils.updateWindowDimensions(this); + }); } hideSidebar() { @@ -59,6 +77,33 @@ export default class SearchResultsItem extends React.Component { unflagPost(this.props.post.id); } + timeTag(post) { + return ( + <time className='search-item-time'> + <FormattedDate + value={post.create_at} + hour12={!this.props.useMilitaryTime} + hour='2-digit' + minute='2-digit' + /> + </time> + ); + } + + renderTimeTag(post) { + return Utils.isMobile() ? + this.timeTag(post) : + ( + <Link + to={`/${this.state.currentTeamDisplayName}/pl/${post.id}`} + target='_blank' + className='post__permalink' + > + {this.timeTag(post)} + </Link> + ); + } + render() { let channelName = null; const channel = this.props.channel; @@ -276,14 +321,7 @@ export default class SearchResultsItem extends React.Component { </strong></li> {botIndicator} <li className='col'> - <time className='search-item-time'> - <FormattedDate - value={post.create_at} - hour12={!this.props.useMilitaryTime} - hour='2-digit' - minute='2-digit' - /> - </time> + {this.renderTimeTag(post)} {flagContent} </li> {rhsControls} |