You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
3.2 KiB

  1. import PureRenderMixin from 'react-addons-pure-render-mixin';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import Avatar from '../../../components/avatar';
  4. import DisplayName from '../../../components/display_name';
  5. import StatusContent from '../../../components/status_content';
  6. import MediaGallery from '../../../components/media_gallery';
  7. import VideoPlayer from '../../../components/video_player';
  8. import { Link } from 'react-router';
  9. import { FormattedDate, FormattedNumber } from 'react-intl';
  10. const DetailedStatus = React.createClass({
  11. contextTypes: {
  12. router: React.PropTypes.object
  13. },
  14. propTypes: {
  15. status: ImmutablePropTypes.map.isRequired,
  16. onOpenMedia: React.PropTypes.func.isRequired
  17. },
  18. mixins: [PureRenderMixin],
  19. handleAccountClick (e) {
  20. if (e.button === 0) {
  21. e.preventDefault();
  22. this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  23. }
  24. e.stopPropagation();
  25. },
  26. render () {
  27. const status = this.props.status.get('reblog') ? this.props.status.get('reblog') : this.props.status;
  28. let media = '';
  29. if (status.get('media_attachments').size > 0) {
  30. if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
  31. media = <VideoPlayer sensitive={status.get('sensitive')} media={status.getIn(['media_attachments', 0])} width={317} height={178} />;
  32. } else {
  33. media = <MediaGallery sensitive={status.get('sensitive')} media={status.get('media_attachments')} height={300} onOpenMedia={this.props.onOpenMedia} />;
  34. }
  35. }
  36. return (
  37. <div style={{ background: '#2f3441', padding: '14px 10px' }} className='detailed-status'>
  38. <a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='detailed-status__display-name' style={{ display: 'block', overflow: 'hidden', marginBottom: '15px' }}>
  39. <div style={{ float: 'left', marginRight: '10px' }}><Avatar src={status.getIn(['account', 'avatar'])} size={48} /></div>
  40. <DisplayName account={status.get('account')} />
  41. </a>
  42. <StatusContent status={status} />
  43. {media}
  44. <div style={{ marginTop: '15px', color: '#616b86', fontSize: '14px', lineHeight: '18px' }}>
  45. <a className='detailed-status__datetime' style={{ color: 'inherit' }} href={status.get('url')} target='_blank' rel='noopener'><FormattedDate value={new Date(status.get('created_at'))} hour12={false} year='numeric' month='short' day='2-digit' hour='2-digit' minute='2-digit' /></a> · <Link to={`/statuses/${status.get('id')}/reblogs`} style={{ color: 'inherit', textDecoration: 'none' }}><i className='fa fa-retweet' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}><FormattedNumber value={status.get('reblogs_count')} /></span></Link> · <Link to={`/statuses/${status.get('id')}/favourites`} style={{ color: 'inherit', textDecoration: 'none' }}><i className='fa fa-star' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}><FormattedNumber value={status.get('favourites_count')} /></span></Link>
  46. </div>
  47. </div>
  48. );
  49. }
  50. });
  51. export default DetailedStatus;