]>
cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/status/components/detailed_status.js
1 import React
from 'react';
2 import PropTypes
from 'prop-types';
3 import ImmutablePropTypes
from 'react-immutable-proptypes';
4 import Avatar
from '../../../components/avatar';
5 import DisplayName
from '../../../components/display_name';
6 import StatusContent
from '../../../components/status_content';
7 import MediaGallery
from '../../../components/media_gallery';
8 import AttachmentList
from '../../../components/attachment_list';
9 import Link
from 'react-router-dom/Link';
10 import { FormattedDate
, FormattedNumber
} from 'react-intl';
11 import CardContainer
from '../containers/card_container';
12 import ImmutablePureComponent
from 'react-immutable-pure-component';
13 import Video
from '../../video';
15 export default class DetailedStatus
extends ImmutablePureComponent
{
17 static contextTypes
= {
18 router: PropTypes
.object
,
22 status: ImmutablePropTypes
.map
.isRequired
,
23 onOpenMedia: PropTypes
.func
.isRequired
,
24 onOpenVideo: PropTypes
.func
.isRequired
,
25 autoPlayGif: PropTypes
.bool
,
28 handleAccountClick
= (e
) => {
31 this.context
.router
.history
.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
37 handleOpenVideo
= startTime
=> {
38 this.props
.onOpenVideo(this.props
.status
.getIn(['media_attachments', 0]), startTime
);
42 const status
= this.props
.status
.get('reblog') ? this.props
.status
.get('reblog') : this.props
.status
;
45 let applicationLink
= '';
47 if (status
.get('media_attachments').size
> 0) {
48 if (status
.get('media_attachments').some(item
=> item
.get('type') === 'unknown')) {
49 media
= <AttachmentList media
={status
.get('media_attachments')} />;
50 } else if (status
.getIn(['media_attachments', 0, 'type']) === 'video') {
51 const video
= status
.getIn(['media_attachments', 0]);
55 preview
={video
.get('preview_url')}
56 src
={video
.get('url')}
59 onOpenVideo
={this.handleOpenVideo
}
60 sensitive
={status
.get('sensitive')}
67 sensitive
={status
.get('sensitive')}
68 media
={status
.get('media_attachments')}
70 onOpenMedia
={this.props
.onOpenMedia
}
71 autoPlayGif
={this.props
.autoPlayGif
}
75 } else if (status
.get('spoiler_text').length
=== 0) {
76 media
= <CardContainer statusId
={status
.get('id')} />;
79 if (status
.get('application')) {
80 applicationLink
= <span
> · <a className
='detailed-status__application' href
={status
.getIn(['application', 'website'])} target
='_blank' rel
='noopener'>{status
.getIn(['application', 'name'])}</a></span>;
84 <div className
='detailed-status'>
85 <a href
={status
.getIn(['account', 'url'])} onClick
={this.handleAccountClick
} className
='detailed-status__display-name'>
86 <div className
='detailed-status__display-avatar'><Avatar account
={status
.get('account')} size
={48} /></div>
87 <DisplayName account
={status
.get('account')} />
90 <StatusContent status
={status
} />
94 <div className
='detailed-status__meta'>
95 <a className
='detailed-status__datetime' href
={status
.get('url')} target
='_blank' rel
='noopener'>
96 <FormattedDate value
={new Date(status
.get('created_at'))} hour12
={false} year
='numeric' month
='short' day
='2-digit' hour
='2-digit' minute
='2-digit' />
97 </a
>{applicationLink
} · <Link to
={`/statuses/${status.get('id')}/reblogs`} className
='detailed-status__link'>
98 <i className
='fa fa-retweet' />
99 <span className
='detailed-status__reblogs'>
100 <FormattedNumber value
={status
.get('reblogs_count')} />
102 </Link
> · <Link to
={`/statuses/${status.get('id')}/favourites`} className
='detailed-status__link'>
103 <i className
='fa fa-star' />
104 <span className
='detailed-status__favorites'>
105 <FormattedNumber value
={status
.get('favourites_count')} />
This page took 0.190879 seconds and 4 git commands to generate.