2017-05-03 10:04:16 +10:00
|
|
|
import React from 'react';
|
2016-08-25 01:56:44 +10:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-22 04:05:35 +10:00
|
|
|
import PropTypes from 'prop-types';
|
2016-11-17 03:20:52 +11:00
|
|
|
import Avatar from './avatar';
|
2017-05-03 19:43:37 +10:00
|
|
|
import AvatarOverlay from './avatar_overlay';
|
2018-10-20 11:23:58 +11:00
|
|
|
import AvatarComposite from './avatar_composite';
|
2016-11-17 03:20:52 +11:00
|
|
|
import RelativeTimestamp from './relative_timestamp';
|
|
|
|
import DisplayName from './display_name';
|
|
|
|
import StatusContent from './status_content';
|
|
|
|
import StatusActionBar from './status_action_bar';
|
2018-03-08 14:54:26 +11:00
|
|
|
import AttachmentList from './attachment_list';
|
2018-10-28 16:35:03 +11:00
|
|
|
import Card from '../features/status/components/card';
|
2020-06-26 06:43:59 +10:00
|
|
|
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
|
2017-05-03 10:04:16 +10:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2019-08-24 06:38:02 +10:00
|
|
|
import { MediaGallery, Video, Audio } from '../features/ui/util/async-components';
|
2017-10-06 10:07:59 +11:00
|
|
|
import { HotKeys } from 'react-hotkeys';
|
|
|
|
import classNames from 'classnames';
|
2019-02-01 10:14:05 +11:00
|
|
|
import Icon from 'mastodon/components/icon';
|
2019-05-26 07:20:51 +10:00
|
|
|
import { displayMedia } from '../initial_state';
|
2017-07-08 08:06:02 +10: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-25 01:56:44 +10:00
|
|
|
|
2018-08-27 01:53:26 +10:00
|
|
|
export const textForScreenReader = (intl, status, rebloggedByText = false) => {
|
2018-08-24 04:56:57 +10:00
|
|
|
const displayName = status.getIn(['account', 'display_name']);
|
|
|
|
|
|
|
|
const values = [
|
|
|
|
displayName.length === 0 ? status.getIn(['account', 'acct']).split('@')[0] : displayName,
|
2018-08-27 01:53:26 +10:00
|
|
|
status.get('spoiler_text') && status.get('hidden') ? status.get('spoiler_text') : status.get('search_index').slice(status.get('spoiler_text').length),
|
2018-08-24 04:56:57 +10: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(', ');
|
|
|
|
};
|
|
|
|
|
2019-05-26 21:48:16 +10:00
|
|
|
export const defaultMediaVisibility = (status) => {
|
|
|
|
if (!status) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
|
|
|
|
status = status.get('reblog');
|
|
|
|
}
|
|
|
|
|
|
|
|
return (displayMedia !== 'hide_all' && !status.get('sensitive') || displayMedia === 'show_all');
|
|
|
|
};
|
|
|
|
|
2020-06-26 06:43:59 +10:00
|
|
|
const messages = defineMessages({
|
|
|
|
public_short: { id: 'privacy.public.short', defaultMessage: 'Public' },
|
|
|
|
unlisted_short: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
|
|
|
|
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
|
|
|
|
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
|
|
|
|
});
|
|
|
|
|
2018-09-15 01:59:48 +10:00
|
|
|
export default @injectIntl
|
|
|
|
class Status extends ImmutablePureComponent {
|
2017-04-22 04:05:35 +10:00
|
|
|
|
2017-05-12 22:44:10 +10:00
|
|
|
static contextTypes = {
|
2017-05-21 01:31:47 +10:00
|
|
|
router: PropTypes.object,
|
2017-05-12 22:44:10 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
status: ImmutablePropTypes.map,
|
|
|
|
account: ImmutablePropTypes.map,
|
2018-10-20 11:23:58 +11:00
|
|
|
otherAccounts: ImmutablePropTypes.list,
|
|
|
|
onClick: PropTypes.func,
|
2017-05-12 22:44:10 +10:00
|
|
|
onReply: PropTypes.func,
|
|
|
|
onFavourite: PropTypes.func,
|
|
|
|
onReblog: PropTypes.func,
|
|
|
|
onDelete: PropTypes.func,
|
2018-04-10 01:09:11 +10:00
|
|
|
onDirect: PropTypes.func,
|
|
|
|
onMention: PropTypes.func,
|
2017-08-25 09:41:18 +10:00
|
|
|
onPin: PropTypes.func,
|
2017-05-12 22:44:10 +10:00
|
|
|
onOpenMedia: PropTypes.func,
|
|
|
|
onOpenVideo: PropTypes.func,
|
|
|
|
onBlock: PropTypes.func,
|
2017-09-02 05:30:13 +10:00
|
|
|
onEmbed: PropTypes.func,
|
2017-08-08 04:32:03 +10:00
|
|
|
onHeightChange: PropTypes.func,
|
2018-03-11 19:52:59 +11:00
|
|
|
onToggleHidden: PropTypes.func,
|
Summary: fix slowness due to layout thrashing when reloading a large … (#12661)
* Summary: fix slowness due to layout thrashing when reloading a large set of status updates
in order to limit the maximum size of a status in a list view (e.g. the home timeline), so as to avoid having to scroll all the way through an abnormally large status update (see https://github.com/tootsuite/mastodon/pull/8205), the following steps are taken:
•the element containing the status is rendered in the browser
•its height is calculated, to determine if it exceeds the maximum height threshold.
Unfortunately for performance, these steps are carried out in the componentDidMount(/Update) method, which also performs style modifications on the element. The combination of height request and style modification during javascript evaluation in the browser leads to layout-thrashing, where the elements are repeatedly re-laid-out (see https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing & https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Performance_best_practices_for_Firefox_fe_engineers).
The solution implemented here is to memoize the collapsed state in Redux the first time the status is seen (e.g. when fetched as part of a small batch, to populate the home timeline) , so that on subsequent re-renders, the value can be queried, rather than recalculated. This strategy is derived from https://github.com/tootsuite/mastodon/pull/4439 & https://github.com/tootsuite/mastodon/pull/4909, and should resolve https://github.com/tootsuite/mastodon/issues/12455.
Andrew Lin (https://github.com/onethreeseven) is thanked for his assistance in root cause analysis and solution brainstorming
* remove getSnapshotBeforeUpdate from status
* remove componentWillUnmount from status
* persist last-intersected status update and restore when ScrollableList is restored
e.g. when navigating from home-timeline to a status conversational thread and <Back again
* cache currently-viewing status id to avoid calling redux with identical value
* refactor collapse toggle to pass explicit boolean
2019-12-29 15:39:48 +11:00
|
|
|
onToggleCollapsed: PropTypes.func,
|
2017-05-21 01:31:47 +10:00
|
|
|
muted: PropTypes.bool,
|
2017-08-29 06:23:44 +10:00
|
|
|
hidden: PropTypes.bool,
|
2018-10-20 11:23:58 +11:00
|
|
|
unread: PropTypes.bool,
|
2017-10-06 10:07:59 +11:00
|
|
|
onMoveUp: PropTypes.func,
|
|
|
|
onMoveDown: PropTypes.func,
|
2018-11-09 07:08:57 +11:00
|
|
|
showThread: PropTypes.bool,
|
2019-02-11 23:19:59 +11:00
|
|
|
getScrollPosition: PropTypes.func,
|
|
|
|
updateScrollBottom: PropTypes.func,
|
|
|
|
cacheMediaWidth: PropTypes.func,
|
|
|
|
cachedMediaWidth: PropTypes.number,
|
2020-07-09 23:09:19 +10:00
|
|
|
scrollKey: PropTypes.string,
|
2017-05-12 22:44:10 +10:00
|
|
|
};
|
|
|
|
|
2017-05-26 22:05:52 +10: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-29 06:23:44 +10:00
|
|
|
'hidden',
|
2019-01-17 05:47:46 +11:00
|
|
|
];
|
2017-05-26 22:05:52 +10:00
|
|
|
|
2019-05-26 07:20:51 +10:00
|
|
|
state = {
|
2019-05-26 21:48:16 +10:00
|
|
|
showMedia: defaultMediaVisibility(this.props.status),
|
2019-05-30 00:33:15 +10:00
|
|
|
statusId: undefined,
|
2019-05-26 07:20:51 +10:00
|
|
|
};
|
|
|
|
|
2019-05-30 00:33:15 +10:00
|
|
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
|
|
if (nextProps.status && nextProps.status.get('id') !== prevState.statusId) {
|
|
|
|
return {
|
|
|
|
showMedia: defaultMediaVisibility(nextProps.status),
|
|
|
|
statusId: nextProps.status.get('id'),
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return null;
|
2019-05-26 21:48:16 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 07:20:51 +10:00
|
|
|
handleToggleMediaVisibility = () => {
|
|
|
|
this.setState({ showMedia: !this.state.showMedia });
|
|
|
|
}
|
|
|
|
|
2017-05-12 22:44:10 +10:00
|
|
|
handleClick = () => {
|
2018-10-20 11:23:58 +11:00
|
|
|
if (this.props.onClick) {
|
|
|
|
this.props.onClick();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-11 23:27:59 +10:00
|
|
|
if (!this.context.router) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-16 08:21:51 +10:00
|
|
|
const { status } = this.props;
|
2017-06-21 04:40:03 +10:00
|
|
|
this.context.router.history.push(`/statuses/${status.getIn(['reblog', 'id'], status.get('id'))}`);
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2016-09-16 08:21:51 +10:00
|
|
|
|
2019-05-26 21:48:45 +10:00
|
|
|
handleExpandClick = (e) => {
|
2019-06-11 03:27:10 +10:00
|
|
|
if (this.props.onClick) {
|
|
|
|
this.props.onClick();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:48:45 +10:00
|
|
|
if (e.button === 0) {
|
|
|
|
if (!this.context.router) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { status } = this.props;
|
|
|
|
this.context.router.history.push(`/statuses/${status.getIn(['reblog', 'id'], status.get('id'))}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-20 04:58:12 +10:00
|
|
|
handleAccountClick = (e) => {
|
2018-08-18 20:50:32 +10: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 22:53:48 +10:00
|
|
|
const id = e.currentTarget.getAttribute('data-id');
|
2016-09-16 08:21:51 +10:00
|
|
|
e.preventDefault();
|
2017-06-21 04:40:03 +10:00
|
|
|
this.context.router.history.push(`/accounts/${id}`);
|
2016-09-16 08:21:51 +10:00
|
|
|
}
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2016-09-13 10:24:40 +10:00
|
|
|
|
2017-06-14 04:46:21 +10:00
|
|
|
handleExpandedToggle = () => {
|
2018-03-11 19:52:59 +11:00
|
|
|
this.props.onToggleHidden(this._properStatus());
|
Summary: fix slowness due to layout thrashing when reloading a large … (#12661)
* Summary: fix slowness due to layout thrashing when reloading a large set of status updates
in order to limit the maximum size of a status in a list view (e.g. the home timeline), so as to avoid having to scroll all the way through an abnormally large status update (see https://github.com/tootsuite/mastodon/pull/8205), the following steps are taken:
•the element containing the status is rendered in the browser
•its height is calculated, to determine if it exceeds the maximum height threshold.
Unfortunately for performance, these steps are carried out in the componentDidMount(/Update) method, which also performs style modifications on the element. The combination of height request and style modification during javascript evaluation in the browser leads to layout-thrashing, where the elements are repeatedly re-laid-out (see https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing & https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Performance_best_practices_for_Firefox_fe_engineers).
The solution implemented here is to memoize the collapsed state in Redux the first time the status is seen (e.g. when fetched as part of a small batch, to populate the home timeline) , so that on subsequent re-renders, the value can be queried, rather than recalculated. This strategy is derived from https://github.com/tootsuite/mastodon/pull/4439 & https://github.com/tootsuite/mastodon/pull/4909, and should resolve https://github.com/tootsuite/mastodon/issues/12455.
Andrew Lin (https://github.com/onethreeseven) is thanked for his assistance in root cause analysis and solution brainstorming
* remove getSnapshotBeforeUpdate from status
* remove componentWillUnmount from status
* persist last-intersected status update and restore when ScrollableList is restored
e.g. when navigating from home-timeline to a status conversational thread and <Back again
* cache currently-viewing status id to avoid calling redux with identical value
* refactor collapse toggle to pass explicit boolean
2019-12-29 15:39:48 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
handleCollapsedToggle = isCollapsed => {
|
|
|
|
this.props.onToggleCollapsed(this._properStatus(), isCollapsed);
|
|
|
|
}
|
2017-06-14 04:46:21 +10:00
|
|
|
|
2017-07-08 08:06:02 +10:00
|
|
|
renderLoadingMediaGallery () {
|
2019-08-24 06:38:02 +10:00
|
|
|
return <div className='media-gallery' style={{ height: '110px' }} />;
|
2017-07-08 08:06:02 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
renderLoadingVideoPlayer () {
|
2019-08-24 06:38:02 +10:00
|
|
|
return <div className='video-player' style={{ height: '110px' }} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLoadingAudioPlayer () {
|
|
|
|
return <div className='audio-player' style={{ height: '110px' }} />;
|
2017-07-08 08:06:02 +10:00
|
|
|
}
|
|
|
|
|
2020-04-25 20:16:05 +10:00
|
|
|
handleOpenVideo = (media, options) => {
|
|
|
|
this.props.onOpenVideo(media, options);
|
2017-10-06 10:07:59 +11:00
|
|
|
}
|
|
|
|
|
2019-11-30 03:02:36 +11:00
|
|
|
handleHotkeyOpenMedia = e => {
|
2019-12-05 10:50:51 +11:00
|
|
|
const { onOpenMedia, onOpenVideo } = this.props;
|
|
|
|
const status = this._properStatus();
|
2019-11-30 03:02:36 +11:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if (status.get('media_attachments').size > 0) {
|
|
|
|
if (status.getIn(['media_attachments', 0, 'type']) === 'audio') {
|
|
|
|
// TODO: toggle play/paused?
|
|
|
|
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
|
2020-04-25 20:16:05 +10:00
|
|
|
onOpenVideo(status.getIn(['media_attachments', 0]), { startTime: 0 });
|
2019-11-30 03:02:36 +11:00
|
|
|
} else {
|
|
|
|
onOpenMedia(status.get('media_attachments'), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-06 10:07:59 +11: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-21 02:14:21 +10:00
|
|
|
handleHotkeyMoveUp = e => {
|
|
|
|
this.props.onMoveUp(this.props.status.get('id'), e.target.getAttribute('data-featured'));
|
2017-10-06 10:07:59 +11:00
|
|
|
}
|
|
|
|
|
2018-04-21 02:14:21 +10:00
|
|
|
handleHotkeyMoveDown = e => {
|
|
|
|
this.props.onMoveDown(this.props.status.get('id'), e.target.getAttribute('data-featured'));
|
2017-10-06 10:07:59 +11:00
|
|
|
}
|
|
|
|
|
2018-04-18 11:33:59 +10:00
|
|
|
handleHotkeyToggleHidden = () => {
|
|
|
|
this.props.onToggleHidden(this._properStatus());
|
|
|
|
}
|
|
|
|
|
2019-05-26 07:20:51 +10:00
|
|
|
handleHotkeyToggleSensitive = () => {
|
|
|
|
this.handleToggleMediaVisibility();
|
|
|
|
}
|
|
|
|
|
2017-10-06 10:07:59 +11: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-14 11:39:10 +10:00
|
|
|
}
|
|
|
|
|
2019-02-11 23:19:59 +11:00
|
|
|
handleRef = c => {
|
|
|
|
this.node = c;
|
|
|
|
}
|
|
|
|
|
2016-08-25 05:08:00 +10:00
|
|
|
render () {
|
2017-05-25 01:55:00 +10:00
|
|
|
let media = null;
|
2018-08-24 04:56:57 +10:00
|
|
|
let statusAvatar, prepend, rebloggedByText;
|
2017-06-21 14:47:36 +10:00
|
|
|
|
2020-07-09 23:09:19 +10:00
|
|
|
const { intl, hidden, featured, otherAccounts, unread, showThread, scrollKey } = this.props;
|
2016-09-06 04:38:31 +10:00
|
|
|
|
2017-10-06 10:07:59 +11:00
|
|
|
let { status, account, ...other } = this.props;
|
|
|
|
|
2016-10-25 20:13:16 +11:00
|
|
|
if (status === null) {
|
2017-05-26 22:07:48 +10:00
|
|
|
return null;
|
2017-05-25 01:55:00 +10:00
|
|
|
}
|
|
|
|
|
2019-08-20 03:00:33 +10: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,
|
|
|
|
toggleHidden: this.handleHotkeyToggleHidden,
|
|
|
|
toggleSensitive: this.handleHotkeyToggleSensitive,
|
2019-11-30 03:02:36 +11:00
|
|
|
openMedia: this.handleHotkeyOpenMedia,
|
2019-08-20 03:00:33 +10:00
|
|
|
};
|
|
|
|
|
2017-08-29 06:23:44 +10:00
|
|
|
if (hidden) {
|
2017-05-25 01:55:00 +10:00
|
|
|
return (
|
2019-08-20 03:00:33 +10:00
|
|
|
<HotKeys handlers={handlers}>
|
|
|
|
<div ref={this.handleRef} className={classNames('status__wrapper', { focusable: !this.props.muted })} tabIndex='0'>
|
|
|
|
{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}
|
|
|
|
{status.get('content')}
|
|
|
|
</div>
|
|
|
|
</HotKeys>
|
2017-05-25 01:55:00 +10:00
|
|
|
);
|
2016-10-25 20:13:16 +11:00
|
|
|
}
|
|
|
|
|
2018-06-29 23:34:36 +10: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 23:19:59 +11:00
|
|
|
<div className='status__wrapper status__wrapper--filtered focusable' tabIndex='0' ref={this.handleRef}>
|
2018-06-29 23:34:36 +10:00
|
|
|
<FormattedMessage id='status.filtered' defaultMessage='Filtered' />
|
|
|
|
</div>
|
|
|
|
</HotKeys>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-03-04 19:19:11 +11:00
|
|
|
if (featured) {
|
|
|
|
prepend = (
|
|
|
|
<div className='status__prepend'>
|
2019-02-01 10:14:05 +11:00
|
|
|
<div className='status__prepend-icon-wrapper'><Icon id='thumb-tack' className='status__prepend-icon' fixedWidth /></div>
|
2018-03-04 19:19:11 +11:00
|
|
|
<FormattedMessage id='status.pinned' defaultMessage='Pinned toot' />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
|
2017-08-08 04:32:03 +10:00
|
|
|
const display_name_html = { __html: status.getIn(['account', 'display_name_html']) };
|
2016-11-19 10:28:42 +11:00
|
|
|
|
2017-10-06 10:07:59 +11:00
|
|
|
prepend = (
|
|
|
|
<div className='status__prepend'>
|
2019-02-01 10:14:05 +11:00
|
|
|
<div className='status__prepend-icon-wrapper'><Icon id='retweet' className='status__prepend-icon' fixedWidth /></div>
|
2018-01-16 04:55:10 +11: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-29 06:23:44 +10:00
|
|
|
</div>
|
2016-09-01 22:12:11 +10:00
|
|
|
);
|
2017-10-06 10:07:59 +11:00
|
|
|
|
2018-08-24 04:56:57 +10:00
|
|
|
rebloggedByText = intl.formatMessage({ id: 'status.reblogged_by', defaultMessage: '{name} boosted' }, { name: status.getIn(['account', 'acct']) });
|
|
|
|
|
2017-10-06 10:07:59 +11:00
|
|
|
account = status.get('account');
|
|
|
|
status = status.get('reblog');
|
2016-09-01 22:12:11 +10:00
|
|
|
}
|
2016-08-25 01:56:44 +10:00
|
|
|
|
2019-06-09 01:40:59 +10:00
|
|
|
if (status.get('media_attachments').size > 0) {
|
2019-04-27 11:24:09 +10:00
|
|
|
if (this.props.muted) {
|
2018-03-08 14:54:26 +11:00
|
|
|
media = (
|
|
|
|
<AttachmentList
|
|
|
|
compact
|
|
|
|
media={status.get('media_attachments')}
|
|
|
|
/>
|
|
|
|
);
|
2019-08-24 06:38:02 +10:00
|
|
|
} else if (status.getIn(['media_attachments', 0, 'type']) === 'audio') {
|
|
|
|
const attachment = status.getIn(['media_attachments', 0]);
|
|
|
|
|
|
|
|
media = (
|
|
|
|
<Bundle fetchComponent={Audio} loading={this.renderLoadingAudioPlayer} >
|
|
|
|
{Component => (
|
|
|
|
<Component
|
|
|
|
src={attachment.get('url')}
|
|
|
|
alt={attachment.get('description')}
|
2020-06-29 21:56:55 +10:00
|
|
|
poster={attachment.get('preview_url') || status.getIn(['account', 'avatar_static'])}
|
2020-07-06 02:28:25 +10:00
|
|
|
backgroundColor={attachment.getIn(['meta', 'colors', 'background'])}
|
|
|
|
foregroundColor={attachment.getIn(['meta', 'colors', 'foreground'])}
|
|
|
|
accentColor={attachment.getIn(['meta', 'colors', 'accent'])}
|
2019-08-24 06:38:02 +10:00
|
|
|
duration={attachment.getIn(['meta', 'original', 'duration'], 0)}
|
2020-06-21 10:27:19 +10:00
|
|
|
width={this.props.cachedMediaWidth}
|
2020-06-23 20:20:14 +10:00
|
|
|
height={110}
|
2020-06-21 10:27:19 +10:00
|
|
|
cacheWidth={this.props.cacheMediaWidth}
|
2019-08-24 06:38:02 +10:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Bundle>
|
|
|
|
);
|
|
|
|
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
|
2019-06-20 07:42:38 +10:00
|
|
|
const attachment = status.getIn(['media_attachments', 0]);
|
2017-09-14 11:39:10 +10:00
|
|
|
|
2017-07-08 08:06:02 +10:00
|
|
|
media = (
|
2017-09-14 11:39:10 +10:00
|
|
|
<Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
|
2018-01-18 02:57:15 +11:00
|
|
|
{Component => (
|
|
|
|
<Component
|
2019-06-20 07:42:38 +10:00
|
|
|
preview={attachment.get('preview_url')}
|
|
|
|
blurhash={attachment.get('blurhash')}
|
|
|
|
src={attachment.get('url')}
|
|
|
|
alt={attachment.get('description')}
|
2019-02-11 23:19:59 +11:00
|
|
|
width={this.props.cachedMediaWidth}
|
2018-01-18 02:57:15 +11:00
|
|
|
height={110}
|
2018-03-02 17:00:04 +11:00
|
|
|
inline
|
2018-01-18 02:57:15 +11:00
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
onOpenVideo={this.handleOpenVideo}
|
2019-02-11 23:19:59 +11:00
|
|
|
cacheWidth={this.props.cacheMediaWidth}
|
2019-05-26 07:20:51 +10:00
|
|
|
visible={this.state.showMedia}
|
|
|
|
onToggleVisibility={this.handleToggleMediaVisibility}
|
2018-01-18 02:57:15 +11:00
|
|
|
/>
|
|
|
|
)}
|
2017-07-08 08:06:02 +10:00
|
|
|
</Bundle>
|
|
|
|
);
|
2016-09-18 02:05:02 +10:00
|
|
|
} else {
|
2017-07-08 08:06:02 +10:00
|
|
|
media = (
|
2018-05-08 21:33:09 +10:00
|
|
|
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery}>
|
2019-02-11 23:19:59 +11: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}
|
2019-05-26 07:20:51 +10:00
|
|
|
visible={this.state.showMedia}
|
|
|
|
onToggleVisibility={this.handleToggleMediaVisibility}
|
2019-02-11 23:19:59 +11:00
|
|
|
/>
|
|
|
|
)}
|
2017-07-08 08:06:02 +10:00
|
|
|
</Bundle>
|
|
|
|
);
|
2016-09-18 02:05:02 +10:00
|
|
|
}
|
2018-10-28 16:35:03 +11: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 23:19:59 +11:00
|
|
|
cacheWidth={this.props.cacheMediaWidth}
|
|
|
|
defaultWidth={this.props.cachedMediaWidth}
|
2020-06-07 01:41:56 +10:00
|
|
|
sensitive={status.get('sensitive')}
|
2018-10-28 16:35:03 +11:00
|
|
|
/>
|
|
|
|
);
|
2016-09-06 04:38:31 +10:00
|
|
|
}
|
|
|
|
|
2019-02-20 06:00:41 +11:00
|
|
|
if (otherAccounts && otherAccounts.size > 0) {
|
2018-10-20 11:23:58 +11:00
|
|
|
statusAvatar = <AvatarComposite accounts={otherAccounts} size={48} />;
|
|
|
|
} else if (account === undefined || account === null) {
|
2017-08-08 03:44:55 +10:00
|
|
|
statusAvatar = <Avatar account={status.get('account')} size={48} />;
|
2018-10-20 11:23:58 +11:00
|
|
|
} else {
|
2017-08-08 03:44:55 +10:00
|
|
|
statusAvatar = <AvatarOverlay account={status.get('account')} friend={account} />;
|
2017-05-03 19:43:37 +10:00
|
|
|
}
|
|
|
|
|
2020-06-26 06:43:59 +10:00
|
|
|
const visibilityIconInfo = {
|
|
|
|
'public': { icon: 'globe', text: intl.formatMessage(messages.public_short) },
|
|
|
|
'unlisted': { icon: 'unlock', text: intl.formatMessage(messages.unlisted_short) },
|
|
|
|
'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
|
|
|
|
'direct': { icon: 'envelope', text: intl.formatMessage(messages.direct_short) },
|
|
|
|
};
|
|
|
|
|
|
|
|
const visibilityIcon = visibilityIconInfo[status.get('visibility')];
|
|
|
|
|
2016-08-25 01:56:44 +10:00
|
|
|
return (
|
2017-10-06 10:07:59 +11:00
|
|
|
<HotKeys handlers={handlers}>
|
2019-04-06 14:02:03 +11: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)} ref={this.handleRef}>
|
2017-10-06 10:07:59 +11:00
|
|
|
{prepend}
|
2016-08-25 05:08:00 +10:00
|
|
|
|
2018-10-20 11:23:58 +11: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')}>
|
2019-05-26 21:48:45 +10:00
|
|
|
<div className='status__expand' onClick={this.handleExpandClick} role='presentation' />
|
2017-10-06 10:07:59 +11:00
|
|
|
<div className='status__info'>
|
2019-10-25 07:44:42 +11:00
|
|
|
<a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener noreferrer'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
|
2020-06-26 06:43:59 +10:00
|
|
|
<span className='status__visibility-icon'><Icon id={visibilityIcon.icon} title={visibilityIcon.text} /></span>
|
2016-08-25 05:08:00 +10:00
|
|
|
|
2019-10-25 07:44:42 +11:00
|
|
|
<a onClick={this.handleAccountClick} data-id={status.getIn(['account', 'id'])} href={status.getIn(['account', 'url'])} title={status.getIn(['account', 'acct'])} className='status__display-name' target='_blank' rel='noopener noreferrer'>
|
2017-10-06 10:07:59 +11:00
|
|
|
<div className='status__avatar'>
|
|
|
|
{statusAvatar}
|
|
|
|
</div>
|
2016-09-01 06:58:10 +10:00
|
|
|
|
2018-10-20 11:23:58 +11:00
|
|
|
<DisplayName account={status.get('account')} others={otherAccounts} />
|
2017-10-06 10:07:59 +11:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
2020-04-01 04:40:23 +11:00
|
|
|
<StatusContent status={status} onClick={this.handleClick} expanded={!status.get('hidden')} showThread={showThread} onExpandedToggle={this.handleExpandedToggle} collapsable onCollapsedToggle={this.handleCollapsedToggle} />
|
2016-08-25 05:08:00 +10:00
|
|
|
|
2017-10-06 10:07:59 +11:00
|
|
|
{media}
|
2016-09-06 04:38:31 +10:00
|
|
|
|
2020-07-09 23:09:19 +10:00
|
|
|
<StatusActionBar scrollKey={scrollKey} status={status} account={account} {...other} />
|
2017-10-06 10:07:59 +11:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</HotKeys>
|
2016-08-25 01:56:44 +10:00
|
|
|
);
|
|
|
|
}
|
2016-09-01 00:15:12 +10:00
|
|
|
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|