2016-08-24 17:56:44 +02:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2016-08-24 21:08:00 +02:00
|
|
|
import Avatar from './avatar';
|
|
|
|
import RelativeTimestamp from './relative_timestamp';
|
2016-08-31 16:15:12 +02:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
2016-08-31 22:58:10 +02:00
|
|
|
import IconButton from './icon_button';
|
2016-09-01 14:12:11 +02:00
|
|
|
import DisplayName from './display_name';
|
2016-09-05 20:38:31 +02:00
|
|
|
import MediaGallery from './media_gallery';
|
2016-09-13 02:24:40 +02:00
|
|
|
import { hashHistory } from 'react-router';
|
2016-08-24 17:56:44 +02:00
|
|
|
|
|
|
|
const Status = React.createClass({
|
2016-08-31 16:15:12 +02:00
|
|
|
|
2016-08-24 17:56:44 +02:00
|
|
|
propTypes: {
|
2016-08-31 22:58:10 +02:00
|
|
|
status: ImmutablePropTypes.map.isRequired,
|
2016-09-13 02:24:40 +02:00
|
|
|
wrapped: React.PropTypes.bool,
|
2016-09-01 13:21:48 +02:00
|
|
|
onReply: React.PropTypes.func,
|
|
|
|
onFavourite: React.PropTypes.func,
|
|
|
|
onReblog: React.PropTypes.func
|
2016-08-24 17:56:44 +02:00
|
|
|
},
|
|
|
|
|
2016-08-31 16:15:12 +02:00
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
2016-08-31 22:58:10 +02:00
|
|
|
handleReplyClick () {
|
|
|
|
this.props.onReply(this.props.status);
|
|
|
|
},
|
|
|
|
|
2016-09-01 13:21:48 +02:00
|
|
|
handleFavouriteClick () {
|
|
|
|
this.props.onFavourite(this.props.status);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleReblogClick () {
|
|
|
|
this.props.onReblog(this.props.status);
|
|
|
|
},
|
|
|
|
|
2016-09-13 02:24:40 +02:00
|
|
|
handleClick () {
|
2016-09-16 00:21:51 +02:00
|
|
|
const { status } = this.props;
|
|
|
|
hashHistory.push(`/statuses/${status.getIn(['reblog', 'id'], status.get('id'))}`);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleAccountClick (id, e) {
|
|
|
|
if (e.button === 0) {
|
|
|
|
e.preventDefault();
|
|
|
|
hashHistory.push(`/accounts/${id}`);
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
2016-09-13 02:24:40 +02:00
|
|
|
},
|
|
|
|
|
2016-08-24 21:08:00 +02:00
|
|
|
render () {
|
2016-08-24 19:23:37 +02:00
|
|
|
var content = { __html: this.props.status.get('content') };
|
2016-09-05 20:38:31 +02:00
|
|
|
var media = '';
|
|
|
|
|
2016-09-01 14:12:11 +02:00
|
|
|
var { status, ...other } = this.props;
|
|
|
|
|
|
|
|
if (status.get('reblog') !== null) {
|
|
|
|
return (
|
2016-09-13 02:24:40 +02:00
|
|
|
<div style={{ cursor: 'pointer' }} onClick={this.handleClick}>
|
2016-09-01 14:12:11 +02:00
|
|
|
<div style={{ marginLeft: '68px', color: '#616b86', padding: '8px 0', paddingBottom: '2px', fontSize: '14px', position: 'relative' }}>
|
|
|
|
<div style={{ position: 'absolute', 'left': '-26px'}}><i className='fa fa-fw fa-retweet'></i></div>
|
2016-09-16 00:21:51 +02:00
|
|
|
<a onClick={this.handleAccountClick.bind(this, status.getIn(['account', 'id']))} href={status.getIn(['account', 'url'])} className='status__display-name'><strong style={{ color: '#616b86'}}>{status.getIn(['account', 'display_name'])}</strong></a> reblogged
|
2016-09-01 14:12:11 +02:00
|
|
|
</div>
|
|
|
|
|
2016-09-13 02:24:40 +02:00
|
|
|
<Status {...other} wrapped={true} status={status.get('reblog')} />
|
2016-09-01 14:12:11 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-08-24 17:56:44 +02:00
|
|
|
|
2016-09-05 20:38:31 +02:00
|
|
|
if (status.get('media_attachments').size > 0) {
|
|
|
|
media = <MediaGallery media={status.get('media_attachments')} />;
|
|
|
|
}
|
|
|
|
|
2016-08-24 17:56:44 +02:00
|
|
|
return (
|
2016-09-13 02:24:40 +02:00
|
|
|
<div style={{ padding: '8px 10px', paddingLeft: '68px', position: 'relative', minHeight: '48px', borderBottom: '1px solid #363c4b', cursor: 'pointer' }} onClick={this.handleClick}>
|
2016-08-31 22:58:10 +02:00
|
|
|
<div style={{ fontSize: '15px' }}>
|
2016-09-01 12:13:41 +02:00
|
|
|
<div style={{ float: 'right', fontSize: '14px' }}>
|
2016-08-31 22:58:10 +02:00
|
|
|
<a href={status.get('url')} className='status__relative-time' style={{ color: '#616b86' }}><RelativeTimestamp timestamp={status.get('created_at')} /></a>
|
|
|
|
</div>
|
2016-08-24 21:08:00 +02:00
|
|
|
|
2016-09-16 00:21:51 +02:00
|
|
|
<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' }}>
|
2016-08-31 22:58:10 +02:00
|
|
|
<div style={{ position: 'absolute', left: '10px', top: '10px', width: '48px', height: '48px' }}>
|
|
|
|
<Avatar src={status.getIn(['account', 'avatar'])} size={48} />
|
2016-08-24 21:08:00 +02:00
|
|
|
</div>
|
|
|
|
|
2016-09-01 14:12:11 +02:00
|
|
|
<DisplayName account={status.get('account')} />
|
2016-08-31 22:58:10 +02:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='status__content' dangerouslySetInnerHTML={content} />
|
2016-08-24 21:08:00 +02:00
|
|
|
|
2016-09-05 20:38:31 +02:00
|
|
|
{media}
|
|
|
|
|
2016-08-31 22:58:10 +02:00
|
|
|
<div style={{ marginTop: '10px', overflow: 'hidden' }}>
|
|
|
|
<div style={{ float: 'left', marginRight: '10px'}}><IconButton title='Reply' icon='reply' onClick={this.handleReplyClick} /></div>
|
2016-09-01 13:21:48 +02:00
|
|
|
<div style={{ float: 'left', marginRight: '10px'}}><IconButton active={status.get('reblogged')} title='Reblog' icon='retweet' onClick={this.handleReblogClick} /></div>
|
|
|
|
<div style={{ float: 'left'}}><IconButton active={status.get('favourited')} title='Favourite' icon='star' onClick={this.handleFavouriteClick} /></div>
|
2016-08-24 21:08:00 +02:00
|
|
|
</div>
|
2016-08-24 17:56:44 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-08-31 16:15:12 +02:00
|
|
|
|
2016-08-24 17:56:44 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
export default Status;
|