2017-11-18 12:11:18 +09:00
|
|
|
import React from 'react';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import StatusPrepend from './status_prepend';
|
|
|
|
import StatusHeader from './status_header';
|
2018-03-13 09:57:28 +09:00
|
|
|
import StatusIcons from './status_icons';
|
2017-11-18 12:11:18 +09:00
|
|
|
import StatusContent from './status_content';
|
|
|
|
import StatusActionBar from './status_action_bar';
|
2022-11-29 17:54:35 +09:00
|
|
|
import StatusReactions from './status_reactions';
|
2018-03-27 22:40:10 +09:00
|
|
|
import AttachmentList from './attachment_list';
|
2018-10-29 22:44:04 +09:00
|
|
|
import Card from '../features/status/components/card';
|
2018-08-28 19:10:40 +09:00
|
|
|
import { injectIntl, FormattedMessage } from 'react-intl';
|
2017-11-18 12:11:18 +09:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2022-10-11 18:23:59 +09:00
|
|
|
import { MediaGallery, Video, Audio } from '../features/ui/util/async-components';
|
2017-11-18 12:11:18 +09:00
|
|
|
import { HotKeys } from 'react-hotkeys';
|
2017-12-04 16:26:40 +09:00
|
|
|
import NotificationOverlayContainer from 'flavours/glitch/features/notifications/containers/overlay_container';
|
2017-11-28 06:17:12 +09:00
|
|
|
import classNames from 'classnames';
|
2022-10-11 17:41:15 +09:00
|
|
|
import { autoUnfoldCW } from 'flavours/glitch/utils/content_warning';
|
2019-03-04 06:18:23 +09:00
|
|
|
import PollContainer from 'flavours/glitch/containers/poll_container';
|
2022-11-30 23:59:37 +09:00
|
|
|
import { displayMedia, visibleReactions } from 'flavours/glitch/initial_state';
|
2020-09-28 20:29:43 +09:00
|
|
|
import PictureInPicturePlaceholder from 'flavours/glitch/components/picture_in_picture_placeholder';
|
2017-11-18 12:11:18 +09: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';
|
|
|
|
|
2018-08-28 19:10:40 +09:00
|
|
|
export const textForScreenReader = (intl, status, rebloggedByText = false, expanded = false) => {
|
|
|
|
const displayName = status.getIn(['account', 'display_name']);
|
|
|
|
|
|
|
|
const values = [
|
|
|
|
displayName.length === 0 ? status.getIn(['account', 'acct']).split('@')[0] : displayName,
|
|
|
|
status.get('spoiler_text') && !expanded ? status.get('spoiler_text') : status.get('search_index').slice(status.get('spoiler_text').length),
|
|
|
|
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-27 01:58:14 +09:00
|
|
|
export const defaultMediaVisibility = (status, settings) => {
|
|
|
|
if (!status) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status.get('reblog', null) !== null && typeof status.get('reblog') === 'object') {
|
|
|
|
status = status.get('reblog');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.getIn(['media', 'reveal_behind_cw']) && !!status.get('spoiler_text')) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (displayMedia !== 'hide_all' && !status.get('sensitive') || displayMedia === 'show_all');
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2019-05-27 01:58:14 +09:00
|
|
|
|
2019-06-30 01:10:54 +09:00
|
|
|
class Status extends ImmutablePureComponent {
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
static propTypes = {
|
2017-11-28 06:17:12 +09:00
|
|
|
containerId: PropTypes.string,
|
2017-11-18 12:11:18 +09:00
|
|
|
id: PropTypes.string,
|
|
|
|
status: ImmutablePropTypes.map,
|
|
|
|
account: ImmutablePropTypes.map,
|
2023-04-24 15:07:03 +09:00
|
|
|
previousId: PropTypes.string,
|
|
|
|
nextInReplyToId: PropTypes.string,
|
|
|
|
rootId: PropTypes.string,
|
2017-11-18 12:11:18 +09:00
|
|
|
onReply: PropTypes.func,
|
|
|
|
onFavourite: PropTypes.func,
|
|
|
|
onReblog: PropTypes.func,
|
2019-04-28 02:08:38 +09:00
|
|
|
onBookmark: PropTypes.func,
|
2017-11-18 12:11:18 +09:00
|
|
|
onDelete: PropTypes.func,
|
2018-04-11 04:38:02 +09:00
|
|
|
onDirect: PropTypes.func,
|
|
|
|
onMention: PropTypes.func,
|
2022-11-25 02:30:52 +09:00
|
|
|
onReactionAdd: PropTypes.func,
|
|
|
|
onReactionRemove: PropTypes.func,
|
2017-11-18 12:11:18 +09:00
|
|
|
onPin: PropTypes.func,
|
|
|
|
onOpenMedia: PropTypes.func,
|
|
|
|
onOpenVideo: PropTypes.func,
|
|
|
|
onBlock: PropTypes.func,
|
2022-08-25 11:27:47 +09:00
|
|
|
onAddFilter: PropTypes.func,
|
2017-11-18 12:11:18 +09:00
|
|
|
onEmbed: PropTypes.func,
|
|
|
|
onHeightChange: PropTypes.func,
|
2022-07-25 03:01:30 +09:00
|
|
|
onToggleHidden: PropTypes.func,
|
2022-09-24 06:00:12 +09:00
|
|
|
onTranslate: PropTypes.func,
|
2022-10-07 17:14:31 +09:00
|
|
|
onInteractionModal: PropTypes.func,
|
2017-11-18 12:11:18 +09:00
|
|
|
muted: PropTypes.bool,
|
|
|
|
hidden: PropTypes.bool,
|
2019-06-09 19:07:23 +09:00
|
|
|
unread: PropTypes.bool,
|
2017-11-18 12:11:18 +09:00
|
|
|
prepend: PropTypes.string,
|
|
|
|
withDismiss: PropTypes.bool,
|
|
|
|
onMoveUp: PropTypes.func,
|
|
|
|
onMoveDown: PropTypes.func,
|
2018-04-16 04:29:03 +09:00
|
|
|
getScrollPosition: PropTypes.func,
|
|
|
|
updateScrollBottom: PropTypes.func,
|
2018-03-29 02:56:46 +09:00
|
|
|
expanded: PropTypes.bool,
|
2018-08-28 19:10:40 +09:00
|
|
|
intl: PropTypes.object.isRequired,
|
2019-02-10 04:54:11 +09:00
|
|
|
cacheMediaWidth: PropTypes.func,
|
|
|
|
cachedMediaWidth: PropTypes.number,
|
2019-06-09 19:07:23 +09:00
|
|
|
onClick: PropTypes.func,
|
2020-07-09 22:09:19 +09:00
|
|
|
scrollKey: PropTypes.string,
|
2020-09-28 20:29:43 +09:00
|
|
|
deployPictureInPicture: PropTypes.func,
|
2022-05-27 23:34:29 +09:00
|
|
|
settings: ImmutablePropTypes.map.isRequired,
|
2023-01-05 21:32:29 +09:00
|
|
|
pictureInPicture: ImmutablePropTypes.contains({
|
2020-11-16 13:16:39 +09:00
|
|
|
inUse: PropTypes.bool,
|
|
|
|
available: PropTypes.bool,
|
|
|
|
}),
|
2017-11-18 12:11:18 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
state = {
|
2018-03-28 22:40:34 +09:00
|
|
|
isCollapsed: false,
|
2018-04-16 04:29:03 +09:00
|
|
|
autoCollapsed: false,
|
2018-08-29 00:16:30 +09:00
|
|
|
isExpanded: undefined,
|
2019-05-27 01:58:14 +09:00
|
|
|
showMedia: undefined,
|
|
|
|
statusId: undefined,
|
|
|
|
revealBehindCW: undefined,
|
2019-06-30 01:10:54 +09:00
|
|
|
showCard: false,
|
2019-07-13 01:53:40 +09:00
|
|
|
forceFilter: undefined,
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09: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',
|
|
|
|
'settings',
|
|
|
|
'prepend',
|
|
|
|
'muted',
|
|
|
|
'notification',
|
2017-11-22 11:27:34 +09:00
|
|
|
'hidden',
|
2018-04-27 02:39:10 +09:00
|
|
|
'expanded',
|
2020-09-16 01:09:08 +09:00
|
|
|
'unread',
|
2020-11-16 13:16:39 +09:00
|
|
|
'pictureInPicture',
|
2023-05-08 03:06:10 +09:00
|
|
|
'previousId',
|
|
|
|
'nextInReplyToId',
|
|
|
|
'rootId',
|
2023-02-04 04:52:07 +09:00
|
|
|
];
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
updateOnStates = [
|
|
|
|
'isExpanded',
|
2018-03-28 22:40:34 +09:00
|
|
|
'isCollapsed',
|
2019-05-27 01:58:14 +09:00
|
|
|
'showMedia',
|
2019-07-13 01:53:40 +09:00
|
|
|
'forceFilter',
|
2023-02-04 04:52:07 +09:00
|
|
|
];
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
// If our settings have changed to disable collapsed statuses, then we
|
|
|
|
// need to make sure that we uncollapse every one. We do that by watching
|
|
|
|
// for changes to `settings.collapsed.enabled` in
|
2018-04-27 03:23:25 +09:00
|
|
|
// `getderivedStateFromProps()`.
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
// We also need to watch for changes on the `collapse` prop---if this
|
|
|
|
// changes to anything other than `undefined`, then we need to collapse or
|
|
|
|
// uncollapse our status accordingly.
|
2018-04-27 03:23:25 +09:00
|
|
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
|
|
let update = {};
|
|
|
|
let updated = false;
|
|
|
|
|
|
|
|
// Make sure the state mirrors props we track…
|
|
|
|
if (nextProps.expanded !== prevState.expandedProp) {
|
|
|
|
update.expandedProp = nextProps.expanded;
|
|
|
|
updated = true;
|
|
|
|
}
|
2022-07-25 03:01:30 +09:00
|
|
|
if (nextProps.status?.get('hidden') !== prevState.statusPropHidden) {
|
|
|
|
update.statusPropHidden = nextProps.status?.get('hidden');
|
|
|
|
updated = true;
|
|
|
|
}
|
2018-04-27 03:23:25 +09:00
|
|
|
|
|
|
|
// Update state based on new props
|
2017-11-18 12:11:18 +09:00
|
|
|
if (!nextProps.settings.getIn(['collapsed', 'enabled'])) {
|
2018-04-27 03:23:25 +09:00
|
|
|
if (prevState.isCollapsed) {
|
|
|
|
update.isCollapsed = false;
|
|
|
|
updated = true;
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
2022-07-25 03:01:30 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle uncollapsing toots when the shared CW state is expanded
|
|
|
|
if (nextProps.settings.getIn(['content_warnings', 'shared_state']) &&
|
|
|
|
nextProps.status?.get('spoiler_text')?.length && nextProps.status?.get('hidden') === false &&
|
|
|
|
prevState.statusPropHidden !== false && prevState.isCollapsed
|
2018-04-27 03:23:25 +09:00
|
|
|
) {
|
2022-07-25 03:01:30 +09:00
|
|
|
update.isCollapsed = false;
|
2018-04-27 03:23:25 +09:00
|
|
|
updated = true;
|
|
|
|
}
|
2022-07-25 03:01:30 +09:00
|
|
|
|
|
|
|
// The “expanded” prop is used to one-off change the local state.
|
|
|
|
// It's used in the thread view when unfolding/re-folding all CWs at once.
|
2018-04-27 03:23:25 +09:00
|
|
|
if (nextProps.expanded !== prevState.expandedProp &&
|
2018-03-29 02:56:46 +09:00
|
|
|
nextProps.expanded !== undefined
|
2018-04-27 03:23:25 +09:00
|
|
|
) {
|
|
|
|
update.isExpanded = nextProps.expanded;
|
|
|
|
if (nextProps.expanded) update.isCollapsed = false;
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
2022-07-25 03:01:30 +09:00
|
|
|
if (prevState.isExpanded === undefined && update.isExpanded === undefined) {
|
|
|
|
update.isExpanded = autoUnfoldCW(nextProps.settings, nextProps.status);
|
|
|
|
updated = true;
|
2018-08-29 00:16:30 +09:00
|
|
|
}
|
|
|
|
|
2019-05-27 01:58:14 +09:00
|
|
|
if (nextProps.status && nextProps.status.get('id') !== prevState.statusId) {
|
|
|
|
update.showMedia = defaultMediaVisibility(nextProps.status, nextProps.settings);
|
|
|
|
update.statusId = nextProps.status.get('id');
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nextProps.settings.getIn(['media', 'reveal_behind_cw']) !== prevState.revealBehindCW) {
|
|
|
|
update.revealBehindCW = nextProps.settings.getIn(['media', 'reveal_behind_cw']);
|
|
|
|
if (update.revealBehindCW) {
|
|
|
|
update.showMedia = defaultMediaVisibility(nextProps.status, nextProps.settings);
|
|
|
|
}
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
2018-04-27 03:23:25 +09:00
|
|
|
return updated ? update : null;
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// When mounting, we just check to see if our status should be collapsed,
|
|
|
|
// and collapse it if so. We don't need to worry about whether collapsing
|
2018-03-28 22:40:34 +09:00
|
|
|
// is enabled here, because `setCollapsed()` already takes that into
|
2017-11-18 12:11:18 +09:00
|
|
|
// account.
|
|
|
|
|
|
|
|
// The cases where a status should be collapsed are:
|
|
|
|
//
|
|
|
|
// - The `collapse` prop has been set to `true`
|
|
|
|
// - The user has decided in local settings to collapse all statuses.
|
|
|
|
// - The user has decided to collapse all notifications ('muted'
|
|
|
|
// statuses).
|
|
|
|
// - The user has decided to collapse long statuses and the status is
|
2023-01-27 03:36:44 +09:00
|
|
|
// over the user set value (default 400 without media, or 610px with).
|
2017-11-18 12:11:18 +09:00
|
|
|
// - The status is a reply and the user has decided to collapse all
|
|
|
|
// replies.
|
|
|
|
// - The status contains media and the user has decided to collapse all
|
|
|
|
// statuses with media.
|
|
|
|
// - The status is a reblog the user has decided to collapse all
|
|
|
|
// statuses which are reblogs.
|
|
|
|
componentDidMount () {
|
|
|
|
const { node } = this;
|
|
|
|
const {
|
|
|
|
status,
|
|
|
|
settings,
|
|
|
|
collapse,
|
|
|
|
muted,
|
|
|
|
prepend,
|
|
|
|
} = this.props;
|
2018-05-27 02:21:02 +09:00
|
|
|
|
|
|
|
// Prevent a crash when node is undefined. Not completely sure why this
|
|
|
|
// happens, might be because status === null.
|
|
|
|
if (node === undefined) return;
|
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
const autoCollapseSettings = settings.getIn(['collapsed', 'auto']);
|
|
|
|
|
2022-07-25 03:01:30 +09:00
|
|
|
// Don't autocollapse if CW state is shared and status is explicitly revealed,
|
|
|
|
// as it could cause surprising changes when receiving notifications
|
|
|
|
if (settings.getIn(['content_warnings', 'shared_state']) && status.get('spoiler_text').length && !status.get('hidden')) return;
|
|
|
|
|
2023-01-27 03:36:44 +09:00
|
|
|
let autoCollapseHeight = parseInt(autoCollapseSettings.get('height'));
|
|
|
|
if (status.get('media_attachments').size && !muted) {
|
|
|
|
autoCollapseHeight += 210;
|
|
|
|
}
|
|
|
|
|
2022-07-25 03:01:30 +09:00
|
|
|
if (collapse ||
|
|
|
|
autoCollapseSettings.get('all') ||
|
|
|
|
(autoCollapseSettings.get('notifications') && muted) ||
|
2023-01-27 03:36:44 +09:00
|
|
|
(autoCollapseSettings.get('lengthy') && node.clientHeight > autoCollapseHeight) ||
|
2022-07-25 03:01:30 +09:00
|
|
|
(autoCollapseSettings.get('reblogs') && prepend === 'reblogged_by') ||
|
|
|
|
(autoCollapseSettings.get('replies') && status.get('in_reply_to_id', null) !== null) ||
|
|
|
|
(autoCollapseSettings.get('media') && !(status.get('spoiler_text').length) && status.get('media_attachments').size > 0)
|
|
|
|
) {
|
2018-03-28 22:40:34 +09:00
|
|
|
this.setCollapsed(true);
|
2018-04-16 04:29:03 +09:00
|
|
|
// Hack to fix timeline jumps on second rendering when auto-collapsing
|
|
|
|
this.setState({ autoCollapsed: true });
|
|
|
|
}
|
2019-02-10 05:24:43 +09:00
|
|
|
|
2019-06-30 01:10:54 +09:00
|
|
|
// Hack to fix timeline jumps when a preview card is fetched
|
|
|
|
this.setState({
|
|
|
|
showCard: !this.props.muted && !this.props.hidden && this.props.status && this.props.status.get('card') && this.props.settings.get('inline_preview_cards'),
|
|
|
|
});
|
2018-04-16 04:29:03 +09:00
|
|
|
}
|
|
|
|
|
2019-06-30 01:10:54 +09:00
|
|
|
// Hack to fix timeline jumps on second rendering when auto-collapsing
|
|
|
|
// or on subsequent rendering when a preview card has been fetched
|
2023-05-08 04:43:25 +09:00
|
|
|
getSnapshotBeforeUpdate() {
|
2019-06-30 01:10:54 +09:00
|
|
|
if (!this.props.getScrollPosition) return null;
|
|
|
|
|
|
|
|
const { muted, hidden, status, settings } = this.props;
|
|
|
|
|
|
|
|
const doShowCard = !muted && !hidden && status && status.get('card') && settings.get('inline_preview_cards');
|
|
|
|
if (this.state.autoCollapsed || (doShowCard && !this.state.showCard)) {
|
|
|
|
if (doShowCard) this.setState({ showCard: true });
|
|
|
|
if (this.state.autoCollapsed) this.setState({ autoCollapsed: false });
|
2018-04-16 04:29:03 +09:00
|
|
|
return this.props.getScrollPosition();
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-08 04:43:25 +09:00
|
|
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
2019-06-30 01:10:54 +09:00
|
|
|
if (snapshot !== null && this.props.updateScrollBottom && this.node.offsetTop < snapshot.top) {
|
|
|
|
this.props.updateScrollBottom(snapshot.height - snapshot.top);
|
2018-04-16 04:29:03 +09:00
|
|
|
}
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
|
|
|
|
2019-02-10 06:08:57 +09:00
|
|
|
componentWillUnmount() {
|
|
|
|
if (this.node && this.props.getScrollPosition) {
|
|
|
|
const position = this.props.getScrollPosition();
|
|
|
|
if (position !== null && this.node.offsetTop < position.top) {
|
2023-02-04 04:52:07 +09:00
|
|
|
requestAnimationFrame(() => {
|
|
|
|
this.props.updateScrollBottom(position.height - position.top);
|
|
|
|
});
|
2019-02-10 06:08:57 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-28 22:40:34 +09:00
|
|
|
// `setCollapsed()` sets the value of `isCollapsed` in our state, that is,
|
|
|
|
// whether the toot is collapsed or not.
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2018-03-28 22:40:34 +09:00
|
|
|
// `setCollapsed()` automatically checks for us whether toot collapsing
|
2017-11-18 12:11:18 +09:00
|
|
|
// is enabled, so we don't have to.
|
2018-03-28 22:40:34 +09:00
|
|
|
setCollapsed = (value) => {
|
|
|
|
if (this.props.settings.getIn(['collapsed', 'enabled'])) {
|
|
|
|
if (value) {
|
|
|
|
this.setExpansion(false);
|
|
|
|
}
|
2022-07-25 03:01:30 +09:00
|
|
|
this.setState({ isCollapsed: value });
|
2018-03-28 22:40:34 +09:00
|
|
|
} else {
|
|
|
|
this.setState({ isCollapsed: false });
|
|
|
|
}
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2018-03-28 22:40:34 +09:00
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
setExpansion = (value) => {
|
2022-07-25 03:01:30 +09:00
|
|
|
if (this.props.settings.getIn(['content_warnings', 'shared_state']) && this.props.status.get('hidden') === value) {
|
|
|
|
this.props.onToggleHidden(this.props.status);
|
|
|
|
}
|
|
|
|
|
2018-03-28 22:40:34 +09:00
|
|
|
this.setState({ isExpanded: value });
|
|
|
|
if (value) {
|
|
|
|
this.setCollapsed(false);
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
// `parseClick()` takes a click event and responds appropriately.
|
|
|
|
// If our status is collapsed, then clicking on it should uncollapse it.
|
|
|
|
// If `Shift` is held, then clicking on it should collapse it.
|
|
|
|
// Otherwise, we open the url handed to us in `destination`, if
|
|
|
|
// applicable.
|
|
|
|
parseClick = (e, destination) => {
|
|
|
|
const { router } = this.context;
|
|
|
|
const { status } = this.props;
|
2018-03-28 22:40:34 +09:00
|
|
|
const { isCollapsed } = this.state;
|
2017-11-18 12:11:18 +09:00
|
|
|
if (!router) return;
|
2019-06-09 19:07:23 +09:00
|
|
|
|
2018-08-11 01:00:30 +09:00
|
|
|
if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey)) {
|
2018-03-28 22:40:34 +09:00
|
|
|
if (isCollapsed) this.setCollapsed(false);
|
2017-11-18 12:11:18 +09:00
|
|
|
else if (e.shiftKey) {
|
2018-03-28 22:40:34 +09:00
|
|
|
this.setCollapsed(true);
|
2017-11-18 12:11:18 +09:00
|
|
|
document.getSelection().removeAllRanges();
|
2019-06-09 19:07:23 +09:00
|
|
|
} else if (this.props.onClick) {
|
|
|
|
this.props.onClick();
|
|
|
|
return;
|
2019-04-16 05:23:05 +09:00
|
|
|
} else {
|
2019-06-09 19:07:23 +09:00
|
|
|
if (destination === undefined) {
|
2021-09-26 12:46:13 +09:00
|
|
|
destination = `/@${
|
|
|
|
status.getIn(['reblog', 'account', 'acct'], status.getIn(['account', 'acct']))
|
|
|
|
}/${
|
2019-06-09 19:07:23 +09:00
|
|
|
status.getIn(['reblog', 'id'], status.get('id'))
|
|
|
|
}`;
|
|
|
|
}
|
2023-02-04 04:52:07 +09:00
|
|
|
let state = { ...router.history.location.state };
|
2019-04-16 05:23:05 +09:00
|
|
|
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
|
|
|
|
router.history.push(destination, state);
|
|
|
|
}
|
2017-11-18 12:11:18 +09:00
|
|
|
e.preventDefault();
|
|
|
|
}
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2019-05-27 01:58:14 +09:00
|
|
|
handleToggleMediaVisibility = () => {
|
|
|
|
this.setState({ showMedia: !this.state.showMedia });
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2019-05-27 01:58:14 +09:00
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
handleExpandedToggle = () => {
|
2022-07-25 03:01:30 +09:00
|
|
|
if (this.props.settings.getIn(['content_warnings', 'shared_state'])) {
|
|
|
|
this.props.onToggleHidden(this.props.status);
|
|
|
|
} else if (this.props.status.get('spoiler_text')) {
|
2018-03-28 22:40:34 +09:00
|
|
|
this.setExpansion(!this.state.isExpanded);
|
2017-11-28 06:17:12 +09:00
|
|
|
}
|
2017-11-18 12:11:18 +09:00
|
|
|
};
|
|
|
|
|
2020-12-07 12:29:37 +09:00
|
|
|
handleOpenVideo = (options) => {
|
|
|
|
const { status } = this.props;
|
|
|
|
this.props.onOpenVideo(status.get('id'), status.getIn(['media_attachments', 0]), options);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2020-11-27 11:24:11 +09:00
|
|
|
|
|
|
|
handleOpenMedia = (media, index) => {
|
|
|
|
this.props.onOpenMedia(this.props.status.get('id'), media, index);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2019-11-30 01:02:36 +09:00
|
|
|
handleHotkeyOpenMedia = e => {
|
|
|
|
const { status, onOpenMedia, onOpenVideo } = this.props;
|
2020-11-27 11:24:11 +09:00
|
|
|
const statusId = status.get('id');
|
2019-11-30 01:02:36 +09:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if (status.get('media_attachments').size > 0) {
|
2020-11-27 11:24:11 +09:00
|
|
|
if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
|
|
|
|
onOpenVideo(statusId, status.getIn(['media_attachments', 0]), { startTime: 0 });
|
2019-11-30 01:02:36 +09:00
|
|
|
} else {
|
2020-11-27 11:24:11 +09:00
|
|
|
onOpenMedia(statusId, status.get('media_attachments'), 0);
|
2019-11-30 01:02:36 +09:00
|
|
|
}
|
|
|
|
}
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2019-11-30 01:02:36 +09:00
|
|
|
|
2020-09-28 20:29:43 +09:00
|
|
|
handleDeployPictureInPicture = (type, mediaProps) => {
|
|
|
|
const { deployPictureInPicture, status } = this.props;
|
|
|
|
|
|
|
|
deployPictureInPicture(status, type, mediaProps);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2020-09-28 20:29:43 +09:00
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
handleHotkeyReply = e => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.onReply(this.props.status, this.context.router.history);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2017-12-10 03:06:00 +09:00
|
|
|
handleHotkeyFavourite = (e) => {
|
2017-12-10 01:26:22 +09:00
|
|
|
this.props.onFavourite(this.props.status, e);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
handleHotkeyBoost = e => {
|
|
|
|
this.props.onReblog(this.props.status, e);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2019-04-28 02:08:38 +09:00
|
|
|
handleHotkeyBookmark = e => {
|
|
|
|
this.props.onBookmark(this.props.status, e);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2019-04-28 02:08:38 +09:00
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
handleHotkeyMention = e => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.onMention(this.props.status.get('account'), this.context.router.history);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
handleHotkeyOpen = () => {
|
2023-02-04 04:52:07 +09:00
|
|
|
let state = { ...this.context.router.history.location.state };
|
2019-04-16 05:23:05 +09:00
|
|
|
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
|
2021-10-07 22:05:24 +09:00
|
|
|
const status = this.props.status;
|
2021-09-26 12:46:13 +09:00
|
|
|
this.context.router.history.push(`/@${status.getIn(['account', 'acct'])}/${status.get('id')}`, state);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
handleHotkeyOpenProfile = () => {
|
2023-02-04 04:52:07 +09:00
|
|
|
let state = { ...this.context.router.history.location.state };
|
2019-04-16 05:23:05 +09:00
|
|
|
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
|
2021-09-26 12:46:13 +09:00
|
|
|
this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`, state);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2018-04-23 05:08:30 +09:00
|
|
|
handleHotkeyMoveUp = e => {
|
|
|
|
this.props.onMoveUp(this.props.containerId || this.props.id, e.target.getAttribute('data-featured'));
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2018-04-23 05:08:30 +09:00
|
|
|
handleHotkeyMoveDown = e => {
|
|
|
|
this.props.onMoveDown(this.props.containerId || this.props.id, e.target.getAttribute('data-featured'));
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2023-05-08 04:43:25 +09:00
|
|
|
handleHotkeyCollapse = () => {
|
2019-04-28 02:17:42 +09:00
|
|
|
if (!this.props.settings.getIn(['collapsed', 'enabled']))
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.setCollapsed(!this.state.isCollapsed);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2019-04-28 02:17:42 +09:00
|
|
|
|
2019-05-27 01:58:14 +09:00
|
|
|
handleHotkeyToggleSensitive = () => {
|
|
|
|
this.handleToggleMediaVisibility();
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2019-04-28 02:17:42 +09:00
|
|
|
|
2019-07-12 23:01:33 +09:00
|
|
|
handleUnfilterClick = e => {
|
2022-06-28 16:42:13 +09:00
|
|
|
this.setState({ forceFilter: false });
|
|
|
|
e.preventDefault();
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2019-07-12 23:01:33 +09:00
|
|
|
|
|
|
|
handleFilterClick = () => {
|
2019-07-13 01:53:40 +09:00
|
|
|
this.setState({ forceFilter: true });
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2019-07-12 23:01:33 +09:00
|
|
|
|
2017-11-19 04:05:23 +09:00
|
|
|
handleRef = c => {
|
|
|
|
this.node = c;
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2017-11-19 04:05:23 +09:00
|
|
|
|
2022-09-24 06:00:12 +09:00
|
|
|
handleTranslate = () => {
|
|
|
|
this.props.onTranslate(this.props.status);
|
2023-02-04 04:52:07 +09:00
|
|
|
};
|
2022-09-24 06:00:12 +09:00
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
renderLoadingMediaGallery () {
|
2019-08-24 05:38:02 +09:00
|
|
|
return <div className='media-gallery' style={{ height: '110px' }} />;
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
renderLoadingVideoPlayer () {
|
2019-08-24 05:38:02 +09:00
|
|
|
return <div className='video-player' style={{ height: '110px' }} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLoadingAudioPlayer () {
|
|
|
|
return <div className='audio-player' style={{ height: '110px' }} />;
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {
|
2017-11-19 04:05:23 +09:00
|
|
|
handleRef,
|
2017-11-18 12:11:18 +09:00
|
|
|
parseClick,
|
2018-03-28 22:40:34 +09:00
|
|
|
setCollapsed,
|
2017-11-18 12:11:18 +09:00
|
|
|
} = this;
|
|
|
|
const { router } = this.context;
|
|
|
|
const {
|
2018-08-28 19:10:40 +09:00
|
|
|
intl,
|
2017-11-18 12:11:18 +09:00
|
|
|
status,
|
|
|
|
account,
|
|
|
|
settings,
|
|
|
|
collapsed,
|
|
|
|
muted,
|
|
|
|
intersectionObserverWrapper,
|
|
|
|
onOpenVideo,
|
|
|
|
onOpenMedia,
|
|
|
|
notification,
|
|
|
|
hidden,
|
2019-06-09 19:07:23 +09:00
|
|
|
unread,
|
2018-04-23 05:08:30 +09:00
|
|
|
featured,
|
2020-11-16 13:16:39 +09:00
|
|
|
pictureInPicture,
|
2023-04-24 15:07:03 +09:00
|
|
|
previousId,
|
|
|
|
nextInReplyToId,
|
|
|
|
rootId,
|
2017-11-18 12:11:18 +09:00
|
|
|
...other
|
|
|
|
} = this.props;
|
2023-05-08 04:43:25 +09:00
|
|
|
const { isCollapsed } = this.state;
|
2017-11-18 12:11:18 +09:00
|
|
|
let background = null;
|
|
|
|
let attachments = null;
|
2022-07-24 18:10:49 +09:00
|
|
|
|
|
|
|
// Depending on user settings, some media are considered as parts of the
|
|
|
|
// contents (affected by CW) while other will be displayed outside of the
|
|
|
|
// CW.
|
|
|
|
let contentMedia = [];
|
|
|
|
let contentMediaIcons = [];
|
|
|
|
let extraMedia = [];
|
|
|
|
let extraMediaIcons = [];
|
|
|
|
let media = contentMedia;
|
|
|
|
let mediaIcons = contentMediaIcons;
|
|
|
|
|
|
|
|
if (settings.getIn(['content_warnings', 'media_outside'])) {
|
|
|
|
media = extraMedia;
|
|
|
|
mediaIcons = extraMediaIcons;
|
|
|
|
}
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
if (status === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-07-25 03:01:30 +09:00
|
|
|
const isExpanded = settings.getIn(['content_warnings', 'shared_state']) ? !status.get('hidden') : this.state.isExpanded;
|
|
|
|
|
2019-08-20 04:14:32 +09:00
|
|
|
const handlers = {
|
|
|
|
reply: this.handleHotkeyReply,
|
|
|
|
favourite: this.handleHotkeyFavourite,
|
|
|
|
boost: this.handleHotkeyBoost,
|
|
|
|
mention: this.handleHotkeyMention,
|
|
|
|
open: this.handleHotkeyOpen,
|
|
|
|
openProfile: this.handleHotkeyOpenProfile,
|
|
|
|
moveUp: this.handleHotkeyMoveUp,
|
|
|
|
moveDown: this.handleHotkeyMoveDown,
|
|
|
|
toggleSpoiler: this.handleExpandedToggle,
|
|
|
|
bookmark: this.handleHotkeyBookmark,
|
|
|
|
toggleCollapse: this.handleHotkeyCollapse,
|
|
|
|
toggleSensitive: this.handleHotkeyToggleSensitive,
|
2019-11-30 01:02:36 +09:00
|
|
|
openMedia: this.handleHotkeyOpenMedia,
|
2019-08-20 04:14:32 +09:00
|
|
|
};
|
|
|
|
|
2023-04-24 15:07:03 +09:00
|
|
|
let prepend, rebloggedByText;
|
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
if (hidden) {
|
|
|
|
return (
|
2019-08-20 04:14:32 +09:00
|
|
|
<HotKeys handlers={handlers}>
|
2023-04-04 23:33:44 +09:00
|
|
|
<div ref={this.handleRef} className='status focusable' tabIndex={0}>
|
2021-07-23 09:53:17 +09:00
|
|
|
<span>{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}</span>
|
|
|
|
<span>{status.get('content')}</span>
|
2019-08-20 04:14:32 +09:00
|
|
|
</div>
|
|
|
|
</HotKeys>
|
2017-11-18 12:11:18 +09:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-04-24 15:07:03 +09:00
|
|
|
const connectUp = previousId && previousId === status.get('in_reply_to_id');
|
|
|
|
const connectToRoot = rootId && rootId === status.get('in_reply_to_id');
|
|
|
|
const connectReply = nextInReplyToId && nextInReplyToId === status.get('id');
|
2022-06-30 16:51:55 +09:00
|
|
|
const matchedFilters = status.get('matched_filters');
|
2023-04-24 15:07:03 +09:00
|
|
|
|
2022-06-28 16:42:13 +09:00
|
|
|
if (this.state.forceFilter === undefined ? matchedFilters : this.state.forceFilter) {
|
2018-07-09 03:04:53 +09:00
|
|
|
const minHandlers = this.props.muted ? {} : {
|
|
|
|
moveUp: this.handleHotkeyMoveUp,
|
|
|
|
moveDown: this.handleHotkeyMoveDown,
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HotKeys handlers={minHandlers}>
|
2023-04-04 23:33:44 +09:00
|
|
|
<div className='status__wrapper status__wrapper--filtered focusable' tabIndex={0} ref={this.handleRef}>
|
2022-06-28 16:42:13 +09:00
|
|
|
<FormattedMessage id='status.filtered' defaultMessage='Filtered' />: {matchedFilters.join(', ')}.
|
|
|
|
{' '}
|
|
|
|
<button className='status__wrapper--filtered__button' onClick={this.handleUnfilterClick}>
|
|
|
|
<FormattedMessage id='status.show_filter_reason' defaultMessage='Show anyway' />
|
|
|
|
</button>
|
2018-07-09 03:04:53 +09:00
|
|
|
</div>
|
|
|
|
</HotKeys>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
// If user backgrounds for collapsed statuses are enabled, then we
|
|
|
|
// initialize our background accordingly. This will only be rendered if
|
|
|
|
// the status is collapsed.
|
|
|
|
if (settings.getIn(['collapsed', 'backgrounds', 'user_backgrounds'])) {
|
|
|
|
background = status.getIn(['account', 'header']);
|
|
|
|
}
|
|
|
|
|
2018-03-27 22:50:05 +09:00
|
|
|
// This handles our media attachments.
|
|
|
|
// If a media file is of unknwon type or if the status is muted
|
|
|
|
// (notification), we show a list of links instead of embedded media.
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
// After we have generated our appropriate media element and stored it in
|
|
|
|
// `media`, we snatch the thumbnail to use as our `background` if media
|
|
|
|
// backgrounds for collapsed statuses are enabled.
|
2021-09-08 21:39:14 +09:00
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
attachments = status.get('media_attachments');
|
2022-04-21 04:29:31 +09:00
|
|
|
|
2023-01-05 21:32:29 +09:00
|
|
|
if (pictureInPicture.get('inUse')) {
|
2023-05-02 20:58:48 +09:00
|
|
|
media.push(<PictureInPicturePlaceholder />);
|
2021-09-08 21:39:14 +09:00
|
|
|
mediaIcons.push('video-camera');
|
2019-03-04 06:18:23 +09:00
|
|
|
} else if (attachments.size > 0) {
|
2018-03-27 22:50:05 +09:00
|
|
|
if (muted || attachments.some(item => item.get('type') === 'unknown')) {
|
2021-09-08 21:39:14 +09:00
|
|
|
media.push(
|
2018-03-27 22:40:10 +09:00
|
|
|
<AttachmentList
|
|
|
|
compact
|
|
|
|
media={status.get('media_attachments')}
|
2021-09-08 21:39:14 +09:00
|
|
|
/>,
|
2018-03-27 22:40:10 +09:00
|
|
|
);
|
2019-08-24 05:38:02 +09:00
|
|
|
} else if (attachments.getIn([0, 'type']) === 'audio') {
|
|
|
|
const attachment = status.getIn(['media_attachments', 0]);
|
|
|
|
|
2021-09-08 21:39:14 +09:00
|
|
|
media.push(
|
2019-08-24 05:38:02 +09:00
|
|
|
<Bundle fetchComponent={Audio} loading={this.renderLoadingAudioPlayer} >
|
|
|
|
{Component => (
|
|
|
|
<Component
|
|
|
|
src={attachment.get('url')}
|
|
|
|
alt={attachment.get('description')}
|
2023-02-27 04:13:27 +09:00
|
|
|
lang={status.get('language')}
|
2020-06-29 20:56:55 +09:00
|
|
|
poster={attachment.get('preview_url') || status.getIn(['account', 'avatar_static'])}
|
2020-07-06 01:28:25 +09:00
|
|
|
backgroundColor={attachment.getIn(['meta', 'colors', 'background'])}
|
|
|
|
foregroundColor={attachment.getIn(['meta', 'colors', 'foreground'])}
|
|
|
|
accentColor={attachment.getIn(['meta', 'colors', 'accent'])}
|
2019-08-24 05:38:02 +09:00
|
|
|
duration={attachment.getIn(['meta', 'original', 'duration'], 0)}
|
2020-06-21 09:27:19 +09:00
|
|
|
width={this.props.cachedMediaWidth}
|
2020-06-23 19:20:14 +09:00
|
|
|
height={110}
|
2020-06-21 09:27:19 +09:00
|
|
|
cacheWidth={this.props.cacheMediaWidth}
|
2023-01-05 21:32:29 +09:00
|
|
|
deployPictureInPicture={pictureInPicture.get('available') ? this.handleDeployPictureInPicture : undefined}
|
2022-08-13 22:39:05 +09:00
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
blurhash={attachment.get('blurhash')}
|
|
|
|
visible={this.state.showMedia}
|
|
|
|
onToggleVisibility={this.handleToggleMediaVisibility}
|
2019-08-24 05:38:02 +09:00
|
|
|
/>
|
|
|
|
)}
|
2021-09-08 21:39:14 +09:00
|
|
|
</Bundle>,
|
2019-08-24 05:38:02 +09:00
|
|
|
);
|
2021-09-08 21:39:14 +09:00
|
|
|
mediaIcons.push('music');
|
2019-08-24 05:38:02 +09:00
|
|
|
} else if (attachments.getIn([0, 'type']) === 'video') {
|
2019-06-20 06:42:38 +09:00
|
|
|
const attachment = status.getIn(['media_attachments', 0]);
|
2017-11-18 12:11:18 +09:00
|
|
|
|
2021-09-08 21:39:14 +09:00
|
|
|
media.push(
|
2017-11-18 12:11:18 +09:00
|
|
|
<Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
|
2018-01-19 00:13:07 +09:00
|
|
|
{Component => (<Component
|
2019-06-20 06:42:38 +09:00
|
|
|
preview={attachment.get('preview_url')}
|
2020-11-22 07:19:04 +09:00
|
|
|
frameRate={attachment.getIn(['meta', 'original', 'frame_rate'])}
|
2019-06-20 06:42:38 +09:00
|
|
|
blurhash={attachment.get('blurhash')}
|
|
|
|
src={attachment.get('url')}
|
|
|
|
alt={attachment.get('description')}
|
2023-02-27 04:13:27 +09:00
|
|
|
lang={status.get('language')}
|
2018-04-15 00:14:04 +09:00
|
|
|
inline
|
2017-11-18 12:11:18 +09:00
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
letterbox={settings.getIn(['media', 'letterbox'])}
|
2023-04-29 19:43:01 +09:00
|
|
|
fullwidth={!rootId && settings.getIn(['media', 'fullwidth'])}
|
2018-09-05 01:50:45 +09:00
|
|
|
preventPlayback={isCollapsed || !isExpanded}
|
2017-11-18 12:11:18 +09:00
|
|
|
onOpenVideo={this.handleOpenVideo}
|
2023-01-05 21:32:29 +09:00
|
|
|
deployPictureInPicture={pictureInPicture.get('available') ? this.handleDeployPictureInPicture : undefined}
|
2019-05-27 01:58:14 +09:00
|
|
|
visible={this.state.showMedia}
|
|
|
|
onToggleVisibility={this.handleToggleMediaVisibility}
|
2018-01-19 00:13:07 +09:00
|
|
|
/>)}
|
2021-09-08 21:39:14 +09:00
|
|
|
</Bundle>,
|
2017-11-18 12:11:18 +09:00
|
|
|
);
|
2021-09-08 21:39:14 +09:00
|
|
|
mediaIcons.push('video-camera');
|
2017-11-18 12:11:18 +09:00
|
|
|
} else { // Media type is 'image' or 'gifv'
|
2021-09-08 21:39:14 +09:00
|
|
|
media.push(
|
2018-08-01 06:03:16 +09:00
|
|
|
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery}>
|
2017-11-18 12:11:18 +09:00
|
|
|
{Component => (
|
|
|
|
<Component
|
|
|
|
media={attachments}
|
2023-02-27 04:13:27 +09:00
|
|
|
lang={status.get('language')}
|
2017-11-18 12:11:18 +09:00
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
letterbox={settings.getIn(['media', 'letterbox'])}
|
2023-04-29 19:43:01 +09:00
|
|
|
fullwidth={!rootId && settings.getIn(['media', 'fullwidth'])}
|
2018-10-21 02:28:54 +09:00
|
|
|
hidden={isCollapsed || !isExpanded}
|
2020-11-27 11:24:11 +09:00
|
|
|
onOpenMedia={this.handleOpenMedia}
|
2019-02-10 04:54:11 +09:00
|
|
|
cacheWidth={this.props.cacheMediaWidth}
|
|
|
|
defaultWidth={this.props.cachedMediaWidth}
|
2019-05-27 01:58:14 +09:00
|
|
|
visible={this.state.showMedia}
|
|
|
|
onToggleVisibility={this.handleToggleMediaVisibility}
|
2017-11-18 12:11:18 +09:00
|
|
|
/>
|
|
|
|
)}
|
2021-09-08 21:39:14 +09:00
|
|
|
</Bundle>,
|
2017-11-18 12:11:18 +09:00
|
|
|
);
|
2021-09-08 21:39:14 +09:00
|
|
|
mediaIcons.push('picture-o');
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!status.get('sensitive') && !(status.get('spoiler_text').length > 0) && settings.getIn(['collapsed', 'backgrounds', 'preview_images'])) {
|
|
|
|
background = attachments.getIn([0, 'preview_url']);
|
|
|
|
}
|
2022-11-11 03:36:12 +09:00
|
|
|
} else if (status.get('card') && settings.get('inline_preview_cards') && !this.props.muted) {
|
2021-09-08 21:39:14 +09:00
|
|
|
media.push(
|
2018-10-29 22:44:04 +09:00
|
|
|
<Card
|
2020-11-27 11:24:11 +09:00
|
|
|
onOpenMedia={this.handleOpenMedia}
|
2018-10-29 22:44:04 +09:00
|
|
|
card={status.get('card')}
|
|
|
|
compact
|
2020-06-07 00:41:56 +09:00
|
|
|
sensitive={status.get('sensitive')}
|
2021-09-08 21:39:14 +09:00
|
|
|
/>,
|
2018-10-29 22:44:04 +09:00
|
|
|
);
|
2021-09-08 21:39:14 +09:00
|
|
|
mediaIcons.push('link');
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
|
|
|
|
2022-04-21 04:29:31 +09:00
|
|
|
if (status.get('poll')) {
|
2023-02-27 04:13:27 +09:00
|
|
|
contentMedia.push(<PollContainer pollId={status.get('poll')} lang={status.get('language')} />);
|
2022-07-24 18:10:49 +09:00
|
|
|
contentMediaIcons.push('tasks');
|
2022-04-21 04:29:31 +09:00
|
|
|
}
|
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
// Here we prepare extra data-* attributes for CSS selectors.
|
|
|
|
// Users can use those for theming, hiding avatars etc via UserStyle
|
|
|
|
const selectorAttribs = {
|
|
|
|
'data-status-by': `@${status.getIn(['account', 'acct'])}`,
|
|
|
|
};
|
|
|
|
|
2022-10-28 17:30:14 +09:00
|
|
|
if (this.props.prepend && account) {
|
2017-11-18 12:11:18 +09:00
|
|
|
const notifKind = {
|
|
|
|
favourite: 'favourited',
|
2022-11-29 12:31:22 +09:00
|
|
|
reaction: 'reacted',
|
2017-11-18 12:11:18 +09:00
|
|
|
reblog: 'boosted',
|
|
|
|
reblogged_by: 'boosted',
|
2020-09-19 00:26:45 +09:00
|
|
|
status: 'posted',
|
2022-10-28 17:30:14 +09:00
|
|
|
}[this.props.prepend];
|
2017-11-18 12:11:18 +09:00
|
|
|
|
|
|
|
selectorAttribs[`data-${notifKind}-by`] = `@${account.get('acct')}`;
|
2022-10-28 17:30:14 +09:00
|
|
|
|
|
|
|
prepend = (
|
|
|
|
<StatusPrepend
|
|
|
|
type={this.props.prepend}
|
|
|
|
account={account}
|
|
|
|
parseClick={parseClick}
|
|
|
|
notificationId={this.props.notificationId}
|
|
|
|
/>
|
|
|
|
);
|
2017-11-18 12:11:18 +09:00
|
|
|
}
|
|
|
|
|
2022-10-28 17:30:14 +09:00
|
|
|
if (this.props.prepend === 'reblog') {
|
2018-08-28 19:10:40 +09:00
|
|
|
rebloggedByText = intl.formatMessage({ id: 'status.reblogged_by', defaultMessage: '{name} boosted' }, { name: account.get('acct') });
|
|
|
|
}
|
|
|
|
|
2017-11-28 06:17:12 +09:00
|
|
|
const computedClass = classNames('status', `status-${status.get('visibility')}`, {
|
2018-03-28 22:40:34 +09:00
|
|
|
collapsed: isCollapsed,
|
|
|
|
'has-background': isCollapsed && background,
|
2018-08-28 18:05:17 +09:00
|
|
|
'status__wrapper-reply': !!status.get('in_reply_to_id'),
|
2023-04-24 15:07:03 +09:00
|
|
|
'status--in-thread': !!rootId,
|
|
|
|
'status--first-in-thread': previousId && (!connectUp || connectToRoot),
|
2020-09-16 00:58:05 +09:00
|
|
|
unread,
|
2017-11-28 06:17:12 +09:00
|
|
|
muted,
|
|
|
|
}, 'focusable');
|
|
|
|
|
2017-11-18 12:11:18 +09:00
|
|
|
return (
|
|
|
|
<HotKeys handlers={handlers}>
|
|
|
|
<div
|
2017-11-28 06:17:12 +09:00
|
|
|
className={computedClass}
|
2018-03-28 22:40:34 +09:00
|
|
|
style={isCollapsed && background ? { backgroundImage: `url(${background})` } : null}
|
2017-11-18 12:11:18 +09:00
|
|
|
{...selectorAttribs}
|
2017-11-19 04:05:23 +09:00
|
|
|
ref={handleRef}
|
2023-04-04 23:33:44 +09:00
|
|
|
tabIndex={0}
|
2018-04-23 05:08:30 +09:00
|
|
|
data-featured={featured ? 'true' : null}
|
2018-08-28 19:10:40 +09:00
|
|
|
aria-label={textForScreenReader(intl, status, rebloggedByText, !status.get('hidden'))}
|
2017-11-18 12:11:18 +09:00
|
|
|
>
|
2022-10-28 17:30:14 +09:00
|
|
|
{!muted && prepend}
|
2023-04-24 15:07:03 +09:00
|
|
|
|
|
|
|
{(connectReply || connectUp || connectToRoot) && <div className={classNames('status__line', { 'status__line--full': connectReply, 'status__line--first': !status.get('in_reply_to_id') && !connectToRoot })} />}
|
|
|
|
|
2018-03-13 09:57:28 +09:00
|
|
|
<header className='status__info'>
|
2018-03-19 02:42:28 +09:00
|
|
|
<span>
|
2022-10-28 17:30:14 +09:00
|
|
|
{muted && prepend}
|
2018-03-28 22:40:34 +09:00
|
|
|
{!muted || !isCollapsed ? (
|
2018-03-19 02:42:28 +09:00
|
|
|
<StatusHeader
|
|
|
|
status={status}
|
|
|
|
friend={account}
|
2018-03-28 22:40:34 +09:00
|
|
|
collapsed={isCollapsed}
|
2018-03-19 02:42:28 +09:00
|
|
|
parseClick={parseClick}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</span>
|
2018-03-13 09:57:28 +09:00
|
|
|
<StatusIcons
|
|
|
|
status={status}
|
2022-07-24 18:10:49 +09:00
|
|
|
mediaIcons={contentMediaIcons.concat(extraMediaIcons)}
|
2018-03-13 09:57:28 +09:00
|
|
|
collapsible={settings.getIn(['collapsed', 'enabled'])}
|
2018-03-28 22:40:34 +09:00
|
|
|
collapsed={isCollapsed}
|
|
|
|
setCollapsed={setCollapsed}
|
2022-05-27 23:34:29 +09:00
|
|
|
settings={settings.get('status_icons')}
|
2017-11-18 12:11:18 +09:00
|
|
|
/>
|
2018-03-13 09:57:28 +09:00
|
|
|
</header>
|
2017-11-18 12:11:18 +09:00
|
|
|
<StatusContent
|
|
|
|
status={status}
|
2022-07-24 18:10:49 +09:00
|
|
|
media={contentMedia}
|
2022-07-24 20:16:03 +09:00
|
|
|
extraMedia={extraMedia}
|
2022-07-24 18:10:49 +09:00
|
|
|
mediaIcons={contentMediaIcons}
|
2017-11-18 12:11:18 +09:00
|
|
|
expanded={isExpanded}
|
2018-03-29 02:56:46 +09:00
|
|
|
onExpandedToggle={this.handleExpandedToggle}
|
2022-09-24 06:00:12 +09:00
|
|
|
onTranslate={this.handleTranslate}
|
2017-11-18 12:11:18 +09:00
|
|
|
parseClick={parseClick}
|
|
|
|
disabled={!router}
|
2019-08-02 01:48:16 +09:00
|
|
|
tagLinks={settings.get('tag_misleading_links')}
|
2019-08-29 05:13:41 +09:00
|
|
|
rewriteMentions={settings.get('rewrite_mentions')}
|
2017-11-18 12:11:18 +09:00
|
|
|
/>
|
2022-07-24 18:10:49 +09:00
|
|
|
|
2022-11-29 17:54:35 +09:00
|
|
|
<StatusReactions
|
2022-11-25 02:30:52 +09:00
|
|
|
statusId={status.get('id')}
|
|
|
|
reactions={status.get('reactions')}
|
2022-11-30 23:59:37 +09:00
|
|
|
numVisible={visibleReactions}
|
2022-11-25 02:30:52 +09:00
|
|
|
addReaction={this.props.onReactionAdd}
|
|
|
|
removeReaction={this.props.onReactionRemove}
|
|
|
|
/>
|
|
|
|
|
2018-09-30 08:44:02 +09:00
|
|
|
{!isCollapsed || !(muted || !settings.getIn(['collapsed', 'show_action_bar'])) ? (
|
2017-11-18 12:11:18 +09:00
|
|
|
<StatusActionBar
|
|
|
|
status={status}
|
|
|
|
account={status.get('account')}
|
2018-08-22 20:17:21 +09:00
|
|
|
showReplyCount={settings.get('show_reply_count')}
|
2022-08-25 11:37:40 +09:00
|
|
|
onFilter={matchedFilters ? this.handleFilterClick : null}
|
2022-06-28 16:42:13 +09:00
|
|
|
{...other}
|
2017-11-18 12:11:18 +09:00
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
{notification ? (
|
|
|
|
<NotificationOverlayContainer
|
|
|
|
notification={notification}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
</HotKeys>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-03-25 07:15:25 +09:00
|
|
|
|
|
|
|
export default injectIntl(Status);
|