2017-05-02 20:04:16 -04:00
|
|
|
import React from 'react';
|
2016-08-24 11:56:44 -04:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-21 14:05:35 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2016-11-16 11:20:52 -05:00
|
|
|
import Avatar from './avatar';
|
2017-05-03 05:43:37 -04:00
|
|
|
import AvatarOverlay from './avatar_overlay';
|
2018-10-19 20:23:58 -04:00
|
|
|
import AvatarComposite from './avatar_composite';
|
2016-11-16 11:20:52 -05:00
|
|
|
import RelativeTimestamp from './relative_timestamp';
|
|
|
|
import DisplayName from './display_name';
|
|
|
|
import StatusContent from './status_content';
|
|
|
|
import StatusActionBar from './status_action_bar';
|
2018-03-07 22:54:26 -05:00
|
|
|
import AttachmentList from './attachment_list';
|
2018-10-28 01:35:03 -04:00
|
|
|
import Card from '../features/status/components/card';
|
2018-08-23 14:56:57 -04:00
|
|
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
2017-05-02 20:04:16 -04:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2017-09-13 21:39:10 -04:00
|
|
|
import { MediaGallery, Video } from '../features/ui/util/async-components';
|
2017-10-05 19:07:59 -04:00
|
|
|
import { HotKeys } from 'react-hotkeys';
|
|
|
|
import classNames from 'classnames';
|
2019-01-31 18:14:05 -05:00
|
|
|
import Icon from 'mastodon/components/icon';
|
2019-03-03 16:18:23 -05:00
|
|
|
import PollContainer from 'mastodon/containers/poll_container';
|
2017-07-07 18:06:02 -04:00
|
|
|
|
|
|
|
// We use the component (and not the container) since we do not want
|
|
|
|
// to use the progress bar to show download progress
|
|
|
|
import Bundle from '../features/ui/components/bundle';
|
2016-08-24 11:56:44 -04:00
|
|
|
|
2018-08-26 11:53:26 -04:00
|
|
|
export const textForScreenReader = (intl, status, rebloggedByText = false) => {
|
2018-08-23 14:56:57 -04:00
|
|
|
const displayName = status.getIn(['account', 'display_name']);
|
|
|
|
|
|
|
|
const values = [
|
|
|
|
displayName.length === 0 ? status.getIn(['account', 'acct']).split('@')[0] : displayName,
|
2018-08-26 11:53:26 -04:00
|
|
|
status.get('spoiler_text') && status.get('hidden') ? status.get('spoiler_text') : status.get('search_index').slice(status.get('spoiler_text').length),
|
2018-08-23 14:56:57 -04:00
|
|
|
intl.formatDate(status.get('created_at'), { hour: '2-digit', minute: '2-digit', month: 'short', day: 'numeric' }),
|
|
|
|
status.getIn(['account', 'acct']),
|
|
|
|
];
|
|
|
|
|
|
|
|
if (rebloggedByText) {
|
|
|
|
values.push(rebloggedByText);
|
|
|
|
}
|
|
|
|
|
|
|
|
return values.join(', ');
|
|
|
|
};
|
|
|
|
|
2018-09-14 11:59:48 -04:00
|
|
|
export default @injectIntl
|
|
|
|
class Status extends ImmutablePureComponent {
|
2017-04-21 14:05:35 -04:00
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
static contextTypes = {
|
2017-05-20 11:31:47 -04:00
|
|
|
router: PropTypes.object,
|
2017-05-12 08:44:10 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
status: ImmutablePropTypes.map,
|
|
|
|
account: ImmutablePropTypes.map,
|
2018-10-19 20:23:58 -04:00
|
|
|
otherAccounts: ImmutablePropTypes.list,
|
|
|
|
onClick: PropTypes.func,
|
2017-05-12 08:44:10 -04:00
|
|
|
onReply: PropTypes.func,
|
|
|
|
onFavourite: PropTypes.func,
|
|
|
|
onReblog: PropTypes.func,
|
|
|
|
onDelete: PropTypes.func,
|
2018-04-09 11:09:11 -04:00
|
|
|
onDirect: PropTypes.func,
|
|
|
|
onMention: PropTypes.func,
|
2017-08-24 19:41:18 -04:00
|
|
|
onPin: PropTypes.func,
|
2017-05-12 08:44:10 -04:00
|
|
|
onOpenMedia: PropTypes.func,
|
|
|
|
onOpenVideo: PropTypes.func,
|
|
|
|
onBlock: PropTypes.func,
|
2017-09-01 15:30:13 -04:00
|
|
|
onEmbed: PropTypes.func,
|
2017-08-07 14:32:03 -04:00
|
|
|
onHeightChange: PropTypes.func,
|
2018-03-11 04:52:59 -04:00
|
|
|
onToggleHidden: PropTypes.func,
|
2017-05-20 11:31:47 -04:00
|
|
|
muted: PropTypes.bool,
|
2017-08-28 16:23:44 -04:00
|
|
|
hidden: PropTypes.bool,
|
2018-10-19 20:23:58 -04:00
|
|
|
unread: PropTypes.bool,
|
2017-10-05 19:07:59 -04:00
|
|
|
onMoveUp: PropTypes.func,
|
|
|
|
onMoveDown: PropTypes.func,
|
2018-11-08 15:08:57 -05:00
|
|
|
showThread: PropTypes.bool,
|
2019-02-11 07:19:59 -05:00
|
|
|
getScrollPosition: PropTypes.func,
|
|
|
|
updateScrollBottom: PropTypes.func,
|
|
|
|
cacheMediaWidth: PropTypes.func,
|
|
|
|
cachedMediaWidth: PropTypes.number,
|
2017-05-12 08:44:10 -04:00
|
|
|
};
|
|
|
|
|
2017-05-26 08:05:52 -04:00
|
|
|
// Avoid checking props that are functions (and whose equality will always
|
|
|
|
// evaluate to false. See react-immutable-pure-component for usage.
|
|
|
|
updateOnProps = [
|
|
|
|
'status',
|
|
|
|
'account',
|
|
|
|
'muted',
|
2017-08-28 16:23:44 -04:00
|
|
|
'hidden',
|
2019-01-16 13:47:46 -05:00
|
|
|
];
|
2017-05-26 08:05:52 -04:00
|
|
|
|
2019-02-11 07:19:59 -05:00
|
|
|
// Track height changes we know about to compensate scrolling
|
|
|
|
componentDidMount () {
|
2019-02-14 11:03:01 -05:00
|
|
|
this.didShowCard = !this.props.muted && !this.props.hidden && this.props.status && this.props.status.get('card');
|
2019-02-11 07:19:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
getSnapshotBeforeUpdate () {
|
|
|
|
if (this.props.getScrollPosition) {
|
|
|
|
return this.props.getScrollPosition();
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compensate height changes
|
|
|
|
componentDidUpdate (prevProps, prevState, snapshot) {
|
2019-02-14 11:03:01 -05:00
|
|
|
const doShowCard = !this.props.muted && !this.props.hidden && this.props.status && this.props.status.get('card');
|
2019-02-11 07:19:59 -05:00
|
|
|
if (doShowCard && !this.didShowCard) {
|
|
|
|
this.didShowCard = true;
|
|
|
|
if (snapshot !== null && this.props.updateScrollBottom) {
|
|
|
|
if (this.node && this.node.offsetTop < snapshot.top) {
|
|
|
|
this.props.updateScrollBottom(snapshot.height - snapshot.top);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
if (this.node && this.props.getScrollPosition) {
|
|
|
|
const position = this.props.getScrollPosition();
|
|
|
|
if (position !== null && this.node.offsetTop < position.top) {
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
this.props.updateScrollBottom(position.height - position.top);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
handleClick = () => {
|
2018-10-19 20:23:58 -04:00
|
|
|
if (this.props.onClick) {
|
|
|
|
this.props.onClick();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-11 09:27:59 -04:00
|
|
|
if (!this.context.router) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-15 18:21:51 -04:00
|
|
|
const { status } = this.props;
|
2017-06-20 14:40:03 -04:00
|
|
|
this.context.router.history.push(`/statuses/${status.getIn(['reblog', 'id'], status.get('id'))}`);
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
2016-09-15 18:21:51 -04:00
|
|
|
|
2017-05-19 14:58:12 -04:00
|
|
|
handleAccountClick = (e) => {
|
2018-08-18 06:50:32 -04:00
|
|
|
if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
Change IDs to strings rather than numbers in API JSON output (#5019)
* Fix JavaScript interface with long IDs
Somewhat predictably, the JS interface handled IDs as numbers, which in
JS are IEEE double-precision floats. This loses some precision when
working with numbers as large as those generated by the new ID scheme,
so we instead handle them here as strings. This is relatively simple,
and doesn't appear to have caused any problems, but should definitely
be tested more thoroughly than the built-in tests. Several days of use
appear to support this working properly.
BREAKING CHANGE:
The major(!) change here is that IDs are now returned as strings by the
REST endpoints, rather than as integers. In practice, relatively few
changes were required to make the existing JS UI work with this change,
but it will likely hit API clients pretty hard: it's an entirely
different type to consume. (The one API client I tested, Tusky, handles
this with no problems, however.)
Twitter ran into this issue when introducing Snowflake IDs, and decided
to instead introduce an `id_str` field in JSON responses. I have opted
to *not* do that, and instead force all IDs to 64-bit integers
represented by strings in one go. (I believe Twitter exacerbated their
problem by rolling out the changes three times: once for statuses, once
for DMs, and once for user IDs, as well as by leaving an integer ID
value in JSON. As they said, "If you’re using the `id` field with JSON
in a Javascript-related language, there is a very high likelihood that
the integers will be silently munged by Javascript interpreters. In most
cases, this will result in behavior such as being unable to load or
delete a specific direct message, because the ID you're sending to the
API is different than the actual identifier associated with the
message." [1]) However, given that this is a significant change for API
users, alternatives or a transition time may be appropriate.
1: https://blog.twitter.com/developer/en_us/a/2011/direct-messages-going-snowflake-on-sep-30-2011.html
* Additional fixes for stringified IDs in JSON
These should be the last two. These were identified using eslint to try
to identify any plain casts to JavaScript numbers. (Some such casts are
legitimate, but these were not.)
Adding the following to .eslintrc.yml will identify casts to numbers:
~~~
no-restricted-syntax:
- warn
- selector: UnaryExpression[operator='+'] > :not(Literal)
message: Avoid the use of unary +
- selector: CallExpression[callee.name='Number']
message: Casting with Number() may coerce string IDs to numbers
~~~
The remaining three casts appear legitimate: two casts to array indices,
one in a server to turn an environment variable into a number.
* Back out RelationshipsController Change
This was made to make a test a bit less flakey, but has nothing to
do with this branch.
* Change internal streaming payloads to stringified IDs as well
Per
https://github.com/tootsuite/mastodon/pull/5019#issuecomment-330736452
we need these changes to send deleted status IDs as strings, not
integers.
2017-09-20 08:53:48 -04:00
|
|
|
const id = e.currentTarget.getAttribute('data-id');
|
2016-09-15 18:21:51 -04:00
|
|
|
e.preventDefault();
|
2017-06-20 14:40:03 -04:00
|
|
|
this.context.router.history.push(`/accounts/${id}`);
|
2016-09-15 18:21:51 -04:00
|
|
|
}
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
2016-09-12 20:24:40 -04:00
|
|
|
|
2017-06-13 14:46:21 -04:00
|
|
|
handleExpandedToggle = () => {
|
2018-03-11 04:52:59 -04:00
|
|
|
this.props.onToggleHidden(this._properStatus());
|
2017-06-13 14:46:21 -04:00
|
|
|
};
|
|
|
|
|
2017-07-07 18:06:02 -04:00
|
|
|
renderLoadingMediaGallery () {
|
|
|
|
return <div className='media_gallery' style={{ height: '110px' }} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLoadingVideoPlayer () {
|
|
|
|
return <div className='media-spoiler-video' style={{ height: '110px' }} />;
|
|
|
|
}
|
|
|
|
|
2018-05-13 07:48:14 -04:00
|
|
|
handleOpenVideo = (media, startTime) => {
|
|
|
|
this.props.onOpenVideo(media, startTime);
|
2017-10-05 19:07:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyReply = e => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.onReply(this._properStatus(), this.context.router.history);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyFavourite = () => {
|
|
|
|
this.props.onFavourite(this._properStatus());
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyBoost = e => {
|
|
|
|
this.props.onReblog(this._properStatus(), e);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyMention = e => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.onMention(this._properStatus().get('account'), this.context.router.history);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyOpen = () => {
|
|
|
|
this.context.router.history.push(`/statuses/${this._properStatus().get('id')}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyOpenProfile = () => {
|
|
|
|
this.context.router.history.push(`/accounts/${this._properStatus().getIn(['account', 'id'])}`);
|
|
|
|
}
|
|
|
|
|
2018-04-20 12:14:21 -04:00
|
|
|
handleHotkeyMoveUp = e => {
|
|
|
|
this.props.onMoveUp(this.props.status.get('id'), e.target.getAttribute('data-featured'));
|
2017-10-05 19:07:59 -04:00
|
|
|
}
|
|
|
|
|
2018-04-20 12:14:21 -04:00
|
|
|
handleHotkeyMoveDown = e => {
|
|
|
|
this.props.onMoveDown(this.props.status.get('id'), e.target.getAttribute('data-featured'));
|
2017-10-05 19:07:59 -04:00
|
|
|
}
|
|
|
|
|
2018-04-17 21:33:59 -04:00
|
|
|
handleHotkeyToggleHidden = () => {
|
|
|
|
this.props.onToggleHidden(this._properStatus());
|
|
|
|
}
|
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
_properStatus () {
|
|
|
|
const { status } = this.props;
|
|
|
|
|
|
|
|
if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
|
|
|
|
return status.get('reblog');
|
|
|
|
} else {
|
|
|
|
return status;
|
|
|
|
}
|
2017-09-13 21:39:10 -04:00
|
|
|
}
|
|
|
|
|
2019-02-11 07:19:59 -05:00
|
|
|
handleRef = c => {
|
|
|
|
this.node = c;
|
|
|
|
}
|
|
|
|
|
2016-08-24 15:08:00 -04:00
|
|
|
render () {
|
2017-05-24 11:55:00 -04:00
|
|
|
let media = null;
|
2018-08-23 14:56:57 -04:00
|
|
|
let statusAvatar, prepend, rebloggedByText;
|
2017-06-21 00:47:36 -04:00
|
|
|
|
2018-11-08 15:08:57 -05:00
|
|
|
const { intl, hidden, featured, otherAccounts, unread, showThread } = this.props;
|
2016-09-05 14:38:31 -04:00
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
let { status, account, ...other } = this.props;
|
|
|
|
|
2016-10-25 05:13:16 -04:00
|
|
|
if (status === null) {
|
2017-05-26 08:07:48 -04:00
|
|
|
return null;
|
2017-05-24 11:55:00 -04:00
|
|
|
}
|
|
|
|
|
2017-08-28 16:23:44 -04:00
|
|
|
if (hidden) {
|
2017-05-24 11:55:00 -04:00
|
|
|
return (
|
2019-02-11 07:19:59 -05:00
|
|
|
<div ref={this.handleRef}>
|
2017-05-24 11:55:00 -04:00
|
|
|
{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}
|
|
|
|
{status.get('content')}
|
2017-08-28 16:23:44 -04:00
|
|
|
</div>
|
2017-05-24 11:55:00 -04:00
|
|
|
);
|
2016-10-25 05:13:16 -04:00
|
|
|
}
|
|
|
|
|
2018-06-29 09:34:36 -04:00
|
|
|
if (status.get('filtered') || status.getIn(['reblog', 'filtered'])) {
|
|
|
|
const minHandlers = this.props.muted ? {} : {
|
|
|
|
moveUp: this.handleHotkeyMoveUp,
|
|
|
|
moveDown: this.handleHotkeyMoveDown,
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HotKeys handlers={minHandlers}>
|
2019-02-11 07:19:59 -05:00
|
|
|
<div className='status__wrapper status__wrapper--filtered focusable' tabIndex='0' ref={this.handleRef}>
|
2018-06-29 09:34:36 -04:00
|
|
|
<FormattedMessage id='status.filtered' defaultMessage='Filtered' />
|
|
|
|
</div>
|
|
|
|
</HotKeys>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-03-04 03:19:11 -05:00
|
|
|
if (featured) {
|
|
|
|
prepend = (
|
|
|
|
<div className='status__prepend'>
|
2019-01-31 18:14:05 -05:00
|
|
|
<div className='status__prepend-icon-wrapper'><Icon id='thumb-tack' className='status__prepend-icon' fixedWidth /></div>
|
2018-03-04 03:19:11 -05:00
|
|
|
<FormattedMessage id='status.pinned' defaultMessage='Pinned toot' />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
|
2017-08-07 14:32:03 -04:00
|
|
|
const display_name_html = { __html: status.getIn(['account', 'display_name_html']) };
|
2016-11-18 18:28:42 -05:00
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
prepend = (
|
|
|
|
<div className='status__prepend'>
|
2019-01-31 18:14:05 -05:00
|
|
|
<div className='status__prepend-icon-wrapper'><Icon id='retweet' className='status__prepend-icon' fixedWidth /></div>
|
2018-01-15 12:55:10 -05:00
|
|
|
<FormattedMessage id='status.reblogged_by' defaultMessage='{name} boosted' values={{ name: <a onClick={this.handleAccountClick} data-id={status.getIn(['account', 'id'])} href={status.getIn(['account', 'url'])} className='status__display-name muted'><bdi><strong dangerouslySetInnerHTML={display_name_html} /></bdi></a> }} />
|
2017-08-28 16:23:44 -04:00
|
|
|
</div>
|
2016-09-01 08:12:11 -04:00
|
|
|
);
|
2017-10-05 19:07:59 -04:00
|
|
|
|
2018-08-23 14:56:57 -04:00
|
|
|
rebloggedByText = intl.formatMessage({ id: 'status.reblogged_by', defaultMessage: '{name} boosted' }, { name: status.getIn(['account', 'acct']) });
|
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
account = status.get('account');
|
|
|
|
status = status.get('reblog');
|
2016-09-01 08:12:11 -04:00
|
|
|
}
|
2016-08-24 11:56:44 -04:00
|
|
|
|
2019-03-03 16:18:23 -05:00
|
|
|
if (status.get('poll')) {
|
|
|
|
media = <PollContainer pollId={status.get('poll')} />;
|
|
|
|
} else if (status.get('media_attachments').size > 0) {
|
2018-03-08 02:22:04 -05:00
|
|
|
if (this.props.muted || status.get('media_attachments').some(item => item.get('type') === 'unknown')) {
|
2018-03-07 22:54:26 -05:00
|
|
|
media = (
|
|
|
|
<AttachmentList
|
|
|
|
compact
|
|
|
|
media={status.get('media_attachments')}
|
|
|
|
/>
|
|
|
|
);
|
2017-04-19 09:37:18 -04:00
|
|
|
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
|
2017-09-13 21:39:10 -04:00
|
|
|
const video = status.getIn(['media_attachments', 0]);
|
|
|
|
|
2017-07-07 18:06:02 -04:00
|
|
|
media = (
|
2017-09-13 21:39:10 -04:00
|
|
|
<Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
|
2018-01-17 10:57:15 -05:00
|
|
|
{Component => (
|
|
|
|
<Component
|
|
|
|
preview={video.get('preview_url')}
|
|
|
|
src={video.get('url')}
|
2018-08-24 17:55:41 -04:00
|
|
|
alt={video.get('description')}
|
2019-02-11 07:19:59 -05:00
|
|
|
width={this.props.cachedMediaWidth}
|
2018-01-17 10:57:15 -05:00
|
|
|
height={110}
|
2018-03-02 01:00:04 -05:00
|
|
|
inline
|
2018-01-17 10:57:15 -05:00
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
onOpenVideo={this.handleOpenVideo}
|
2019-02-11 07:19:59 -05:00
|
|
|
cacheWidth={this.props.cacheMediaWidth}
|
2018-01-17 10:57:15 -05:00
|
|
|
/>
|
|
|
|
)}
|
2017-07-07 18:06:02 -04:00
|
|
|
</Bundle>
|
|
|
|
);
|
2016-09-17 12:05:02 -04:00
|
|
|
} else {
|
2017-07-07 18:06:02 -04:00
|
|
|
media = (
|
2018-05-08 07:33:09 -04:00
|
|
|
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery}>
|
2019-02-11 07:19:59 -05:00
|
|
|
{Component => (
|
|
|
|
<Component
|
|
|
|
media={status.get('media_attachments')}
|
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
height={110}
|
|
|
|
onOpenMedia={this.props.onOpenMedia}
|
|
|
|
cacheWidth={this.props.cacheMediaWidth}
|
|
|
|
defaultWidth={this.props.cachedMediaWidth}
|
|
|
|
/>
|
|
|
|
)}
|
2017-07-07 18:06:02 -04:00
|
|
|
</Bundle>
|
|
|
|
);
|
2016-09-17 12:05:02 -04:00
|
|
|
}
|
2018-10-28 01:35:03 -04:00
|
|
|
} else if (status.get('spoiler_text').length === 0 && status.get('card')) {
|
|
|
|
media = (
|
|
|
|
<Card
|
|
|
|
onOpenMedia={this.props.onOpenMedia}
|
|
|
|
card={status.get('card')}
|
|
|
|
compact
|
2019-02-11 07:19:59 -05:00
|
|
|
cacheWidth={this.props.cacheMediaWidth}
|
|
|
|
defaultWidth={this.props.cachedMediaWidth}
|
2018-10-28 01:35:03 -04:00
|
|
|
/>
|
|
|
|
);
|
2016-09-05 14:38:31 -04:00
|
|
|
}
|
|
|
|
|
2019-02-19 14:00:41 -05:00
|
|
|
if (otherAccounts && otherAccounts.size > 0) {
|
2018-10-19 20:23:58 -04:00
|
|
|
statusAvatar = <AvatarComposite accounts={otherAccounts} size={48} />;
|
|
|
|
} else if (account === undefined || account === null) {
|
2017-08-07 13:44:55 -04:00
|
|
|
statusAvatar = <Avatar account={status.get('account')} size={48} />;
|
2018-10-19 20:23:58 -04:00
|
|
|
} else {
|
2017-08-07 13:44:55 -04:00
|
|
|
statusAvatar = <AvatarOverlay account={status.get('account')} friend={account} />;
|
2017-05-03 05:43:37 -04:00
|
|
|
}
|
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
const handlers = this.props.muted ? {} : {
|
|
|
|
reply: this.handleHotkeyReply,
|
|
|
|
favourite: this.handleHotkeyFavourite,
|
|
|
|
boost: this.handleHotkeyBoost,
|
|
|
|
mention: this.handleHotkeyMention,
|
|
|
|
open: this.handleHotkeyOpen,
|
|
|
|
openProfile: this.handleHotkeyOpenProfile,
|
|
|
|
moveUp: this.handleHotkeyMoveUp,
|
|
|
|
moveDown: this.handleHotkeyMoveDown,
|
2018-04-17 21:33:59 -04:00
|
|
|
toggleHidden: this.handleHotkeyToggleHidden,
|
2017-10-05 19:07:59 -04:00
|
|
|
};
|
|
|
|
|
2016-08-24 11:56:44 -04:00
|
|
|
return (
|
2017-10-05 19:07:59 -04:00
|
|
|
<HotKeys handlers={handlers}>
|
2019-02-11 07:19:59 -05:00
|
|
|
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility')}`, { 'status__wrapper-reply': !!status.get('in_reply_to_id'), read: unread === false, focusable: !this.props.muted })} tabIndex={this.props.muted ? null : 0} data-featured={featured ? 'true' : null} aria-label={textForScreenReader(intl, status, rebloggedByText, !status.get('hidden'))} ref={this.handleRef}>
|
2017-10-05 19:07:59 -04:00
|
|
|
{prepend}
|
2016-08-24 15:08:00 -04:00
|
|
|
|
2018-10-19 20:23:58 -04:00
|
|
|
<div className={classNames('status', `status-${status.get('visibility')}`, { 'status-reply': !!status.get('in_reply_to_id'), muted: this.props.muted, read: unread === false })} data-id={status.get('id')}>
|
2017-10-05 19:07:59 -04:00
|
|
|
<div className='status__info'>
|
|
|
|
<a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
|
2016-08-24 15:08:00 -04:00
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
<a onClick={this.handleAccountClick} target='_blank' data-id={status.getIn(['account', 'id'])} href={status.getIn(['account', 'url'])} title={status.getIn(['account', 'acct'])} className='status__display-name'>
|
|
|
|
<div className='status__avatar'>
|
|
|
|
{statusAvatar}
|
|
|
|
</div>
|
2016-08-31 16:58:10 -04:00
|
|
|
|
2018-10-19 20:23:58 -04:00
|
|
|
<DisplayName account={status.get('account')} others={otherAccounts} />
|
2017-10-05 19:07:59 -04:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
2018-09-27 11:04:33 -04:00
|
|
|
<StatusContent status={status} onClick={this.handleClick} expanded={!status.get('hidden')} onExpandedToggle={this.handleExpandedToggle} collapsable />
|
2016-08-24 15:08:00 -04:00
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
{media}
|
2016-09-05 14:38:31 -04:00
|
|
|
|
2018-11-08 15:08:57 -05:00
|
|
|
{showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) && (
|
|
|
|
<button className='status__content__read-more-button' onClick={this.handleClick}>
|
|
|
|
<FormattedMessage id='status.show_thread' defaultMessage='Show thread' />
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
|
2017-10-05 19:07:59 -04:00
|
|
|
<StatusActionBar status={status} account={account} {...other} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</HotKeys>
|
2016-08-24 11:56:44 -04:00
|
|
|
);
|
|
|
|
}
|
2016-08-31 10:15:12 -04:00
|
|
|
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|