2017-11-18 05:11:18 +02: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 02:57:28 +02:00
|
|
|
import StatusIcons from './status_icons';
|
2017-11-18 05:11:18 +02:00
|
|
|
import StatusContent from './status_content';
|
|
|
|
import StatusActionBar from './status_action_bar';
|
2018-03-27 16:40:10 +03:00
|
|
|
import AttachmentList from './attachment_list';
|
2017-11-18 05:11:18 +02:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2017-12-04 09:26:40 +02:00
|
|
|
import { MediaGallery, Video } from 'flavours/glitch/util/async-components';
|
2017-11-18 05:11:18 +02:00
|
|
|
import { HotKeys } from 'react-hotkeys';
|
2017-12-04 09:26:40 +02:00
|
|
|
import NotificationOverlayContainer from 'flavours/glitch/features/notifications/containers/overlay_container';
|
2017-11-27 23:17:12 +02:00
|
|
|
import classNames from 'classnames';
|
2017-11-18 05:11:18 +02: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';
|
|
|
|
|
|
|
|
export default class Status extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
static propTypes = {
|
2017-11-27 23:17:12 +02:00
|
|
|
containerId: PropTypes.string,
|
2017-11-18 05:11:18 +02:00
|
|
|
id: PropTypes.string,
|
|
|
|
status: ImmutablePropTypes.map,
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
onReply: PropTypes.func,
|
|
|
|
onFavourite: PropTypes.func,
|
|
|
|
onReblog: PropTypes.func,
|
|
|
|
onDelete: PropTypes.func,
|
2018-04-10 22:38:02 +03:00
|
|
|
onDirect: PropTypes.func,
|
|
|
|
onMention: PropTypes.func,
|
2017-11-18 05:11:18 +02:00
|
|
|
onPin: PropTypes.func,
|
|
|
|
onOpenMedia: PropTypes.func,
|
|
|
|
onOpenVideo: PropTypes.func,
|
|
|
|
onBlock: PropTypes.func,
|
|
|
|
onEmbed: PropTypes.func,
|
|
|
|
onHeightChange: PropTypes.func,
|
|
|
|
muted: PropTypes.bool,
|
|
|
|
collapse: PropTypes.bool,
|
|
|
|
hidden: PropTypes.bool,
|
|
|
|
prepend: PropTypes.string,
|
|
|
|
withDismiss: PropTypes.bool,
|
|
|
|
onMoveUp: PropTypes.func,
|
|
|
|
onMoveDown: PropTypes.func,
|
2018-04-15 22:29:03 +03:00
|
|
|
getScrollPosition: PropTypes.func,
|
|
|
|
updateScrollBottom: PropTypes.func,
|
2018-03-28 20:56:46 +03:00
|
|
|
expanded: PropTypes.bool,
|
2017-11-18 05:11:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
state = {
|
2018-03-28 16:40:34 +03:00
|
|
|
isCollapsed: false,
|
2018-04-15 22:29:03 +03:00
|
|
|
autoCollapsed: false,
|
2017-11-18 05:11:18 +02: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',
|
|
|
|
'boostModal',
|
2017-12-09 18:26:22 +02:00
|
|
|
'favouriteModal',
|
2017-11-18 05:11:18 +02:00
|
|
|
'muted',
|
|
|
|
'collapse',
|
|
|
|
'notification',
|
2017-11-22 04:27:34 +02:00
|
|
|
'hidden',
|
2018-04-26 20:39:10 +03:00
|
|
|
'expanded',
|
2017-11-18 05:11:18 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
updateOnStates = [
|
|
|
|
'isExpanded',
|
2018-03-28 16:40:34 +03:00
|
|
|
'isCollapsed',
|
2017-11-18 05:11:18 +02: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-26 21:23:25 +03:00
|
|
|
// `getderivedStateFromProps()`.
|
2017-11-18 05:11:18 +02: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-26 21:23:25 +03:00
|
|
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
|
|
let update = {};
|
|
|
|
let updated = false;
|
|
|
|
|
|
|
|
// Make sure the state mirrors props we track…
|
|
|
|
if (nextProps.collapse !== prevState.collapseProp) {
|
|
|
|
update.collapseProp = nextProps.collapse;
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
if (nextProps.expanded !== prevState.expandedProp) {
|
|
|
|
update.expandedProp = nextProps.expanded;
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update state based on new props
|
2017-11-18 05:11:18 +02:00
|
|
|
if (!nextProps.settings.getIn(['collapsed', 'enabled'])) {
|
2018-04-26 21:23:25 +03:00
|
|
|
if (prevState.isCollapsed) {
|
|
|
|
update.isCollapsed = false;
|
|
|
|
updated = true;
|
2017-11-18 05:11:18 +02:00
|
|
|
}
|
|
|
|
} else if (
|
2018-04-26 21:23:25 +03:00
|
|
|
nextProps.collapse !== prevState.collapseProp &&
|
2017-11-18 05:11:18 +02:00
|
|
|
nextProps.collapse !== undefined
|
2018-04-26 21:23:25 +03:00
|
|
|
) {
|
|
|
|
update.isCollapsed = nextProps.collapse;
|
|
|
|
if (nextProps.collapse) update.isExpanded = false;
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
if (nextProps.expanded !== prevState.expandedProp &&
|
2018-03-28 20:56:46 +03:00
|
|
|
nextProps.expanded !== undefined
|
2018-04-26 21:23:25 +03:00
|
|
|
) {
|
|
|
|
update.isExpanded = nextProps.expanded;
|
|
|
|
if (nextProps.expanded) update.isCollapsed = false;
|
|
|
|
updated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return updated ? update : null;
|
2017-11-18 05:11:18 +02: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 16:40:34 +03:00
|
|
|
// is enabled here, because `setCollapsed()` already takes that into
|
2017-11-18 05:11:18 +02: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
|
|
|
|
// over 400px (without media, or 650px with).
|
|
|
|
// - 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-26 20:21:02 +03: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 05:11:18 +02:00
|
|
|
const autoCollapseSettings = settings.getIn(['collapsed', 'auto']);
|
|
|
|
|
|
|
|
if (function () {
|
|
|
|
switch (true) {
|
2018-01-14 23:29:51 +02:00
|
|
|
case !!collapse:
|
|
|
|
case !!autoCollapseSettings.get('all'):
|
|
|
|
case autoCollapseSettings.get('notifications') && !!muted:
|
2017-11-18 05:11:18 +02:00
|
|
|
case autoCollapseSettings.get('lengthy') && node.clientHeight > (
|
|
|
|
status.get('media_attachments').size && !muted ? 650 : 400
|
|
|
|
):
|
|
|
|
case autoCollapseSettings.get('reblogs') && prepend === 'reblogged_by':
|
|
|
|
case autoCollapseSettings.get('replies') && status.get('in_reply_to_id', null) !== null:
|
2018-01-14 23:29:51 +02:00
|
|
|
case autoCollapseSettings.get('media') && !(status.get('spoiler_text').length) && !!status.get('media_attachments').size:
|
2017-11-18 05:11:18 +02:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2018-04-15 22:29:03 +03:00
|
|
|
}()) {
|
2018-03-28 16:40:34 +03:00
|
|
|
this.setCollapsed(true);
|
2018-04-15 22:29:03 +03:00
|
|
|
// Hack to fix timeline jumps on second rendering when auto-collapsing
|
|
|
|
this.setState({ autoCollapsed: true });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getSnapshotBeforeUpdate (prevProps, prevState) {
|
|
|
|
if (this.props.getScrollPosition) {
|
|
|
|
return this.props.getScrollPosition();
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hack to fix timeline jumps on second rendering when auto-collapsing
|
|
|
|
componentDidUpdate (prevProps, prevState, snapshot) {
|
|
|
|
if (this.state.autoCollapsed) {
|
|
|
|
this.setState({ autoCollapsed: false });
|
|
|
|
if (snapshot !== null && this.props.updateScrollBottom) {
|
|
|
|
if (this.node.offsetTop < snapshot.top) {
|
|
|
|
this.props.updateScrollBottom(snapshot.height - snapshot.top);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-11-18 05:11:18 +02:00
|
|
|
}
|
|
|
|
|
2018-03-28 16:40:34 +03:00
|
|
|
// `setCollapsed()` sets the value of `isCollapsed` in our state, that is,
|
|
|
|
// whether the toot is collapsed or not.
|
2017-11-18 05:11:18 +02:00
|
|
|
|
2018-03-28 16:40:34 +03:00
|
|
|
// `setCollapsed()` automatically checks for us whether toot collapsing
|
2017-11-18 05:11:18 +02:00
|
|
|
// is enabled, so we don't have to.
|
2018-03-28 16:40:34 +03:00
|
|
|
setCollapsed = (value) => {
|
|
|
|
if (this.props.settings.getIn(['collapsed', 'enabled'])) {
|
|
|
|
this.setState({ isCollapsed: value });
|
|
|
|
if (value) {
|
|
|
|
this.setExpansion(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.setState({ isCollapsed: false });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-18 05:11:18 +02:00
|
|
|
setExpansion = (value) => {
|
2018-03-28 16:40:34 +03:00
|
|
|
this.setState({ isExpanded: value });
|
|
|
|
if (value) {
|
|
|
|
this.setCollapsed(false);
|
2017-11-18 05:11:18 +02: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 16:40:34 +03:00
|
|
|
const { isCollapsed } = this.state;
|
2017-11-18 05:11:18 +02:00
|
|
|
if (!router) return;
|
|
|
|
if (destination === undefined) {
|
|
|
|
destination = `/statuses/${
|
|
|
|
status.getIn(['reblog', 'id'], status.get('id'))
|
|
|
|
}`;
|
|
|
|
}
|
|
|
|
if (e.button === 0) {
|
2018-03-28 16:40:34 +03:00
|
|
|
if (isCollapsed) this.setCollapsed(false);
|
2017-11-18 05:11:18 +02:00
|
|
|
else if (e.shiftKey) {
|
2018-03-28 16:40:34 +03:00
|
|
|
this.setCollapsed(true);
|
2017-11-18 05:11:18 +02:00
|
|
|
document.getSelection().removeAllRanges();
|
|
|
|
} else router.history.push(destination);
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleAccountClick = (e) => {
|
|
|
|
if (this.context.router && e.button === 0) {
|
|
|
|
const id = e.currentTarget.getAttribute('data-id');
|
|
|
|
e.preventDefault();
|
|
|
|
this.context.router.history.push(`/accounts/${id}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleExpandedToggle = () => {
|
2017-11-27 23:17:12 +02:00
|
|
|
if (this.props.status.get('spoiler_text')) {
|
2018-03-28 16:40:34 +03:00
|
|
|
this.setExpansion(!this.state.isExpanded);
|
2017-11-27 23:17:12 +02:00
|
|
|
}
|
2017-11-18 05:11:18 +02:00
|
|
|
};
|
|
|
|
|
2018-05-17 18:10:17 +03:00
|
|
|
handleOpenVideo = (media, startTime) => {
|
|
|
|
this.props.onOpenVideo(media, startTime);
|
2017-11-18 05:11:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyReply = e => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.onReply(this.props.status, this.context.router.history);
|
|
|
|
}
|
|
|
|
|
2017-12-09 20:06:00 +02:00
|
|
|
handleHotkeyFavourite = (e) => {
|
2017-12-09 18:26:22 +02:00
|
|
|
this.props.onFavourite(this.props.status, e);
|
2017-11-18 05:11:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyBoost = e => {
|
|
|
|
this.props.onReblog(this.props.status, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyMention = e => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.onMention(this.props.status.get('account'), this.context.router.history);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyOpen = () => {
|
|
|
|
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleHotkeyOpenProfile = () => {
|
|
|
|
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
|
|
|
|
}
|
|
|
|
|
2018-04-22 23:08:30 +03:00
|
|
|
handleHotkeyMoveUp = e => {
|
|
|
|
this.props.onMoveUp(this.props.containerId || this.props.id, e.target.getAttribute('data-featured'));
|
2017-11-18 05:11:18 +02:00
|
|
|
}
|
|
|
|
|
2018-04-22 23:08:30 +03:00
|
|
|
handleHotkeyMoveDown = e => {
|
|
|
|
this.props.onMoveDown(this.props.containerId || this.props.id, e.target.getAttribute('data-featured'));
|
2017-11-18 05:11:18 +02:00
|
|
|
}
|
|
|
|
|
2017-11-18 21:05:23 +02:00
|
|
|
handleRef = c => {
|
|
|
|
this.node = c;
|
|
|
|
}
|
|
|
|
|
2017-11-18 05:11:18 +02:00
|
|
|
renderLoadingMediaGallery () {
|
|
|
|
return <div className='media_gallery' style={{ height: '110px' }} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLoadingVideoPlayer () {
|
|
|
|
return <div className='media-spoiler-video' style={{ height: '110px' }} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {
|
2017-11-18 21:05:23 +02:00
|
|
|
handleRef,
|
2017-11-18 05:11:18 +02:00
|
|
|
parseClick,
|
|
|
|
setExpansion,
|
2018-03-28 16:40:34 +03:00
|
|
|
setCollapsed,
|
2017-11-18 05:11:18 +02:00
|
|
|
} = this;
|
|
|
|
const { router } = this.context;
|
|
|
|
const {
|
|
|
|
status,
|
|
|
|
account,
|
|
|
|
settings,
|
|
|
|
collapsed,
|
|
|
|
muted,
|
|
|
|
prepend,
|
|
|
|
intersectionObserverWrapper,
|
|
|
|
onOpenVideo,
|
|
|
|
onOpenMedia,
|
|
|
|
notification,
|
|
|
|
hidden,
|
2018-04-22 23:08:30 +03:00
|
|
|
featured,
|
2017-11-18 05:11:18 +02:00
|
|
|
...other
|
|
|
|
} = this.props;
|
2018-03-28 16:40:34 +03:00
|
|
|
const { isExpanded, isCollapsed } = this.state;
|
2017-11-18 05:11:18 +02:00
|
|
|
let background = null;
|
|
|
|
let attachments = null;
|
|
|
|
let media = null;
|
|
|
|
let mediaIcon = null;
|
|
|
|
|
|
|
|
if (status === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hidden) {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
ref={this.handleRef}
|
|
|
|
data-id={status.get('id')}
|
|
|
|
style={{
|
|
|
|
height: `${this.height}px`,
|
|
|
|
opacity: 0,
|
|
|
|
overflow: 'hidden',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])}
|
|
|
|
{' '}
|
|
|
|
{status.get('content')}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 16:50:05 +03: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 05:11:18 +02: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.
|
|
|
|
attachments = status.get('media_attachments');
|
2018-03-27 16:50:05 +03:00
|
|
|
if (attachments.size > 0) {
|
|
|
|
if (muted || attachments.some(item => item.get('type') === 'unknown')) {
|
2018-03-27 16:40:10 +03:00
|
|
|
media = (
|
|
|
|
<AttachmentList
|
|
|
|
compact
|
|
|
|
media={status.get('media_attachments')}
|
|
|
|
/>
|
|
|
|
);
|
2017-11-18 05:11:18 +02:00
|
|
|
} else if (attachments.getIn([0, 'type']) === 'video') { // Media type is 'video'
|
|
|
|
const video = status.getIn(['media_attachments', 0]);
|
|
|
|
|
|
|
|
media = (
|
|
|
|
<Bundle fetchComponent={Video} loading={this.renderLoadingVideoPlayer} >
|
2018-01-18 17:13:07 +02:00
|
|
|
{Component => (<Component
|
2017-11-18 05:11:18 +02:00
|
|
|
preview={video.get('preview_url')}
|
|
|
|
src={video.get('url')}
|
2018-04-14 18:14:04 +03:00
|
|
|
inline
|
2017-11-18 05:11:18 +02:00
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
letterbox={settings.getIn(['media', 'letterbox'])}
|
|
|
|
fullwidth={settings.getIn(['media', 'fullwidth'])}
|
|
|
|
onOpenVideo={this.handleOpenVideo}
|
2018-01-18 17:13:07 +02:00
|
|
|
/>)}
|
2017-11-18 05:11:18 +02:00
|
|
|
</Bundle>
|
|
|
|
);
|
|
|
|
mediaIcon = 'video-camera';
|
|
|
|
} else { // Media type is 'image' or 'gifv'
|
|
|
|
media = (
|
|
|
|
<Bundle fetchComponent={MediaGallery} loading={this.renderLoadingMediaGallery} >
|
|
|
|
{Component => (
|
|
|
|
<Component
|
|
|
|
media={attachments}
|
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
letterbox={settings.getIn(['media', 'letterbox'])}
|
|
|
|
fullwidth={settings.getIn(['media', 'fullwidth'])}
|
|
|
|
onOpenMedia={this.props.onOpenMedia}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Bundle>
|
|
|
|
);
|
|
|
|
mediaIcon = 'picture-o';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!status.get('sensitive') && !(status.get('spoiler_text').length > 0) && settings.getIn(['collapsed', 'backgrounds', 'preview_images'])) {
|
|
|
|
background = attachments.getIn([0, 'preview_url']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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'])}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (prepend && account) {
|
|
|
|
const notifKind = {
|
|
|
|
favourite: 'favourited',
|
|
|
|
reblog: 'boosted',
|
|
|
|
reblogged_by: 'boosted',
|
|
|
|
}[prepend];
|
|
|
|
|
|
|
|
selectorAttribs[`data-${notifKind}-by`] = `@${account.get('acct')}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2017-11-27 23:17:12 +02:00
|
|
|
toggleSpoiler: this.handleExpandedToggle,
|
2017-11-18 05:11:18 +02:00
|
|
|
};
|
|
|
|
|
2017-11-27 23:17:12 +02:00
|
|
|
const computedClass = classNames('status', `status-${status.get('visibility')}`, {
|
2018-03-28 16:40:34 +03:00
|
|
|
collapsed: isCollapsed,
|
|
|
|
'has-background': isCollapsed && background,
|
2017-11-27 23:17:12 +02:00
|
|
|
muted,
|
|
|
|
}, 'focusable');
|
|
|
|
|
2017-11-18 05:11:18 +02:00
|
|
|
return (
|
|
|
|
<HotKeys handlers={handlers}>
|
|
|
|
<div
|
2017-11-27 23:17:12 +02:00
|
|
|
className={computedClass}
|
2018-03-28 16:40:34 +03:00
|
|
|
style={isCollapsed && background ? { backgroundImage: `url(${background})` } : null}
|
2017-11-18 05:11:18 +02:00
|
|
|
{...selectorAttribs}
|
2017-11-18 21:05:23 +02:00
|
|
|
ref={handleRef}
|
2017-11-27 23:17:12 +02:00
|
|
|
tabIndex='0'
|
2018-04-22 23:08:30 +03:00
|
|
|
data-featured={featured ? 'true' : null}
|
2017-11-18 05:11:18 +02:00
|
|
|
>
|
2018-03-13 02:57:28 +02:00
|
|
|
<header className='status__info'>
|
2018-03-18 19:42:28 +02:00
|
|
|
<span>
|
|
|
|
{prepend && account ? (
|
|
|
|
<StatusPrepend
|
|
|
|
type={prepend}
|
|
|
|
account={account}
|
|
|
|
parseClick={parseClick}
|
|
|
|
notificationId={this.props.notificationId}
|
|
|
|
/>
|
|
|
|
) : null}
|
2018-03-28 16:40:34 +03:00
|
|
|
{!muted || !isCollapsed ? (
|
2018-03-18 19:42:28 +02:00
|
|
|
<StatusHeader
|
|
|
|
status={status}
|
|
|
|
friend={account}
|
2018-03-28 16:40:34 +03:00
|
|
|
collapsed={isCollapsed}
|
2018-03-18 19:42:28 +02:00
|
|
|
parseClick={parseClick}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</span>
|
2018-03-13 02:57:28 +02:00
|
|
|
<StatusIcons
|
|
|
|
status={status}
|
|
|
|
mediaIcon={mediaIcon}
|
|
|
|
collapsible={settings.getIn(['collapsed', 'enabled'])}
|
2018-03-28 16:40:34 +03:00
|
|
|
collapsed={isCollapsed}
|
|
|
|
setCollapsed={setCollapsed}
|
2017-11-18 05:11:18 +02:00
|
|
|
/>
|
2018-03-13 02:57:28 +02:00
|
|
|
</header>
|
2017-11-18 05:11:18 +02:00
|
|
|
<StatusContent
|
|
|
|
status={status}
|
|
|
|
media={media}
|
|
|
|
mediaIcon={mediaIcon}
|
|
|
|
expanded={isExpanded}
|
2018-03-28 20:56:46 +03:00
|
|
|
onExpandedToggle={this.handleExpandedToggle}
|
2017-11-18 05:11:18 +02:00
|
|
|
parseClick={parseClick}
|
|
|
|
disabled={!router}
|
|
|
|
/>
|
2018-03-28 16:40:34 +03:00
|
|
|
{!isCollapsed || !muted ? (
|
2017-11-18 05:11:18 +02:00
|
|
|
<StatusActionBar
|
|
|
|
{...other}
|
|
|
|
status={status}
|
|
|
|
account={status.get('account')}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
{notification ? (
|
|
|
|
<NotificationOverlayContainer
|
|
|
|
notification={notification}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
</HotKeys>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|