The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

108 line
3.9 KiB

  1. import ImmutablePropTypes from 'react-immutable-proptypes';
  2. import Avatar from './avatar';
  3. import RelativeTimestamp from './relative_timestamp';
  4. import PureRenderMixin from 'react-addons-pure-render-mixin';
  5. import DisplayName from './display_name';
  6. import MediaGallery from './media_gallery';
  7. import VideoPlayer from './video_player';
  8. import StatusContent from './status_content';
  9. import StatusActionBar from './status_action_bar';
  10. const Status = React.createClass({
  11. contextTypes: {
  12. router: React.PropTypes.object
  13. },
  14. propTypes: {
  15. status: ImmutablePropTypes.map,
  16. wrapped: React.PropTypes.bool,
  17. onReply: React.PropTypes.func,
  18. onFavourite: React.PropTypes.func,
  19. onReblog: React.PropTypes.func,
  20. onDelete: React.PropTypes.func,
  21. onOpenMedia: React.PropTypes.func,
  22. me: React.PropTypes.number,
  23. now: React.PropTypes.any
  24. },
  25. mixins: [PureRenderMixin],
  26. handleClick () {
  27. const { status } = this.props;
  28. this.context.router.push(`/statuses/${status.getIn(['reblog', 'id'], status.get('id'))}`);
  29. },
  30. handleAccountClick (id, e) {
  31. if (e.button === 0) {
  32. e.preventDefault();
  33. this.context.router.push(`/accounts/${id}`);
  34. }
  35. e.stopPropagation();
  36. },
  37. render () {
  38. let media = '';
  39. const { status, now, ...other } = this.props;
  40. if (status === null) {
  41. return <div />;
  42. }
  43. if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
  44. let displayName = status.getIn(['account', 'display_name']);
  45. if (displayName.length === 0) {
  46. displayName = status.getIn(['account', 'username']);
  47. }
  48. return (
  49. <div style={{ cursor: 'default' }}>
  50. <div style={{ marginLeft: '68px', color: '#616b86', padding: '8px 0', paddingBottom: '2px', fontSize: '14px', position: 'relative' }}>
  51. <div style={{ position: 'absolute', 'left': '-26px'}}><i className='fa fa-fw fa-retweet'></i></div>
  52. <a onClick={this.handleAccountClick.bind(this, status.getIn(['account', 'id']))} href={status.getIn(['account', 'url'])} className='status__display-name'><strong style={{ color: '#616b86'}}>{displayName}</strong></a> reblogged
  53. </div>
  54. <Status {...other} wrapped={true} status={status.get('reblog')} />
  55. </div>
  56. );
  57. }
  58. if (status.get('media_attachments').size > 0) {
  59. if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
  60. media = <VideoPlayer media={status.getIn(['media_attachments', 0])} />;
  61. } else {
  62. media = <MediaGallery media={status.get('media_attachments')} height={110} onOpenMedia={this.props.onOpenMedia} />;
  63. }
  64. }
  65. return (
  66. <div style={{ padding: '8px 10px', paddingLeft: '68px', position: 'relative', minHeight: '48px', borderBottom: '1px solid #363c4b', cursor: 'default' }}>
  67. <div style={{ fontSize: '15px' }}>
  68. <div style={{ float: 'right', fontSize: '14px' }}>
  69. <a href={status.get('url')} className='status__relative-time' style={{ color: '#616b86' }} target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} now={now} /></a>
  70. </div>
  71. <a onClick={this.handleAccountClick.bind(this, status.getIn(['account', 'id']))} href={status.getIn(['account', 'url'])} className='status__display-name' style={{ display: 'block', maxWidth: '100%', paddingRight: '25px', color: '#616b86' }}>
  72. <div style={{ position: 'absolute', left: '10px', top: '10px', width: '48px', height: '48px' }}>
  73. <Avatar src={status.getIn(['account', 'avatar'])} size={48} />
  74. </div>
  75. <DisplayName account={status.get('account')} />
  76. </a>
  77. </div>
  78. <StatusContent status={status} onClick={this.handleClick} />
  79. {media}
  80. <StatusActionBar {...this.props} />
  81. </div>
  82. );
  83. }
  84. });
  85. export default Status;