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.

76 lines
3.8 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. import CardContainer from '../containers/card_container';
  11. const DetailedStatus = React.createClass({
  12. contextTypes: {
  13. router: React.PropTypes.object
  14. },
  15. propTypes: {
  16. status: ImmutablePropTypes.map.isRequired,
  17. onOpenMedia: React.PropTypes.func.isRequired,
  18. onOpenVideo: React.PropTypes.func.isRequired,
  19. autoPlayGif: React.PropTypes.bool,
  20. },
  21. mixins: [PureRenderMixin],
  22. handleAccountClick (e) {
  23. if (e.button === 0) {
  24. e.preventDefault();
  25. this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  26. }
  27. e.stopPropagation();
  28. },
  29. render () {
  30. const status = this.props.status.get('reblog') ? this.props.status.get('reblog') : this.props.status;
  31. let media = '';
  32. let applicationLink = '';
  33. if (status.get('media_attachments').size > 0) {
  34. if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
  35. media = <VideoPlayer sensitive={status.get('sensitive')} media={status.getIn(['media_attachments', 0])} width={300} height={150} onOpenVideo={this.props.onOpenVideo} autoplay />;
  36. } else {
  37. media = <MediaGallery sensitive={status.get('sensitive')} media={status.get('media_attachments')} height={300} onOpenMedia={this.props.onOpenMedia} autoPlayGif={this.props.autoPlayGif} />;
  38. }
  39. } else if (status.get('spoiler_text').length === 0) {
  40. media = <CardContainer statusId={status.get('id')} />;
  41. }
  42. if (status.get('application')) {
  43. applicationLink = <span> · <a className='detailed-status__application' style={{ color: 'inherit' }} href={status.getIn(['application', 'website'])} target='_blank' rel='nooopener'>{status.getIn(['application', 'name'])}</a></span>;
  44. }
  45. return (
  46. <div style={{ padding: '14px 10px' }} className='detailed-status'>
  47. <a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='detailed-status__display-name' style={{ display: 'block', overflow: 'hidden', marginBottom: '15px' }}>
  48. <div style={{ float: 'left', marginRight: '10px' }}><Avatar src={status.getIn(['account', 'avatar'])} staticSrc={status.getIn(['account', 'avatar_static'])} size={48} /></div>
  49. <DisplayName account={status.get('account')} />
  50. </a>
  51. <StatusContent status={status} />
  52. {media}
  53. <div className='detailed-status__meta'>
  54. <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>{applicationLink} · <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>
  55. </div>
  56. </div>
  57. );
  58. }
  59. });
  60. export default DetailedStatus;