2022-01-10 14:17:52 -08:00
|
|
|
import classNames from 'classnames';
|
2020-03-27 13:59:38 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2020-03-27 13:59:38 -07:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2022-01-10 14:17:52 -08:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2022-01-27 08:26:39 -08:00
|
|
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
2022-01-10 14:01:24 -08:00
|
|
|
import { FormattedDate } from 'react-intl';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { Link, NavLink } from 'react-router-dom';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import Icon from 'soapbox/components/icon';
|
2022-01-23 09:44:17 -08:00
|
|
|
import QuotedStatus from 'soapbox/features/status/containers/quoted_status_container';
|
2022-01-10 14:01:24 -08:00
|
|
|
import { getDomain } from 'soapbox/utils/accounts';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:17:52 -08:00
|
|
|
import MediaGallery from '../../../components/media_gallery';
|
2020-03-27 13:59:38 -07:00
|
|
|
import StatusContent from '../../../components/status_content';
|
2022-01-04 12:06:08 -08:00
|
|
|
import StatusReplyMentions from '../../../components/status_reply_mentions';
|
2022-03-21 11:09:01 -07:00
|
|
|
import { HStack, Text } from '../../../components/ui';
|
|
|
|
import AccountContainer from '../../../containers/account_container';
|
2020-06-24 19:53:25 -07:00
|
|
|
import Audio from '../../audio';
|
2020-03-27 13:59:38 -07:00
|
|
|
import scheduleIdleTask from '../../ui/util/schedule_idle_task';
|
2022-01-10 14:17:52 -08:00
|
|
|
import Video from '../../video';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import Card from './card';
|
2020-12-24 16:17:53 -08:00
|
|
|
import StatusInteractionBar from './status_interaction_bar';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2022-01-04 12:06:08 -08:00
|
|
|
export default @injectIntl
|
|
|
|
class DetailedStatus extends ImmutablePureComponent {
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
static propTypes = {
|
2022-03-23 10:14:42 -07:00
|
|
|
status: ImmutablePropTypes.record,
|
2020-03-27 13:59:38 -07:00
|
|
|
onOpenMedia: PropTypes.func.isRequired,
|
|
|
|
onOpenVideo: PropTypes.func.isRequired,
|
|
|
|
onToggleHidden: PropTypes.func.isRequired,
|
|
|
|
measureHeight: PropTypes.bool,
|
|
|
|
onHeightChange: PropTypes.func,
|
2020-05-16 11:57:22 -07:00
|
|
|
domain: PropTypes.string,
|
2020-03-27 13:59:38 -07:00
|
|
|
compact: PropTypes.bool,
|
|
|
|
showMedia: PropTypes.bool,
|
|
|
|
onToggleMediaVisibility: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
state = {
|
|
|
|
height: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleOpenVideo = (media, startTime) => {
|
|
|
|
this.props.onOpenVideo(media, startTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleExpandedToggle = () => {
|
|
|
|
this.props.onToggleHidden(this.props.status);
|
|
|
|
}
|
|
|
|
|
2020-04-14 14:47:35 -07:00
|
|
|
_measureHeight(heightJustChanged) {
|
2020-03-27 13:59:38 -07:00
|
|
|
if (this.props.measureHeight && this.node) {
|
|
|
|
scheduleIdleTask(() => this.node && this.setState({ height: Math.ceil(this.node.scrollHeight) + 1 }));
|
|
|
|
|
|
|
|
if (this.props.onHeightChange && heightJustChanged) {
|
|
|
|
this.props.onHeightChange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setRef = c => {
|
|
|
|
this.node = c;
|
|
|
|
this._measureHeight();
|
2022-03-21 11:09:01 -07:00
|
|
|
|
|
|
|
if (c) {
|
|
|
|
this.setState({ mediaWrapperWidth: c.offsetWidth });
|
|
|
|
}
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
|
|
|
|
2020-04-14 14:47:35 -07:00
|
|
|
componentDidUpdate(prevProps, prevState) {
|
2020-03-27 13:59:38 -07:00
|
|
|
this._measureHeight(prevState.height !== this.state.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModalLink = e => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
let href;
|
|
|
|
|
|
|
|
if (e.target.nodeName !== 'A') {
|
|
|
|
href = e.target.parentNode.href;
|
|
|
|
} else {
|
|
|
|
href = e.target.href;
|
|
|
|
}
|
|
|
|
|
2020-05-28 15:52:07 -07:00
|
|
|
window.open(href, 'soapbox-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes');
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
|
|
|
|
2020-04-14 14:47:35 -07:00
|
|
|
render() {
|
2020-03-27 13:59:38 -07:00
|
|
|
const status = (this.props.status && this.props.status.get('reblog')) ? this.props.status.get('reblog') : this.props.status;
|
|
|
|
const outerStyle = { boxSizing: 'border-box' };
|
|
|
|
const { compact } = this.props;
|
2020-09-02 20:38:04 -07:00
|
|
|
const favicon = status.getIn(['account', 'pleroma', 'favicon']);
|
|
|
|
const domain = getDomain(status.get('account'));
|
2021-06-16 13:20:14 -07:00
|
|
|
const size = status.get('media_attachments').size;
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
if (!status) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-10-14 12:14:13 -07:00
|
|
|
let media = null;
|
|
|
|
let statusTypeIcon = null;
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
if (this.props.measureHeight) {
|
|
|
|
outerStyle.height = `${this.state.height}px`;
|
|
|
|
}
|
|
|
|
|
2021-06-16 13:20:14 -07:00
|
|
|
if (size > 0) {
|
|
|
|
if (size === 1 && status.getIn(['media_attachments', 0, 'type']) === 'video') {
|
2020-03-27 13:59:38 -07:00
|
|
|
const video = status.getIn(['media_attachments', 0]);
|
2022-03-21 11:09:01 -07:00
|
|
|
const external_id = (video.get('external_video_id'));
|
|
|
|
if (external_id) {
|
|
|
|
const { mediaWrapperWidth } = this.state;
|
|
|
|
const height = mediaWrapperWidth / (video.getIn(['meta', 'original', 'width']) / video.getIn(['meta', 'original', 'height']));
|
|
|
|
media = (
|
|
|
|
<div className='status-card horizontal interactive status-card--video'>
|
|
|
|
<div
|
|
|
|
ref={this.setRef}
|
|
|
|
className='status-card-video'
|
|
|
|
style={{ height }}
|
|
|
|
>
|
|
|
|
<iframe
|
|
|
|
src={`https://rumble.com/embed/${external_id}/`}
|
|
|
|
frameborder='0'
|
|
|
|
allowFullScreen='true'
|
|
|
|
webkitallowfullscreen='true'
|
|
|
|
mozallowfullscreen='true'
|
|
|
|
title='Video'
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
media = (
|
|
|
|
<Video
|
|
|
|
preview={video.get('preview_url')}
|
|
|
|
blurhash={video.get('blurhash')}
|
|
|
|
src={video.get('url')}
|
|
|
|
alt={video.get('description')}
|
|
|
|
aspectRatio={video.getIn(['meta', 'original', 'aspect'])}
|
|
|
|
width={300}
|
|
|
|
height={150}
|
|
|
|
inline
|
|
|
|
onOpenVideo={this.handleOpenVideo}
|
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
visible={this.props.showMedia}
|
|
|
|
onToggleVisibility={this.props.onToggleMediaVisibility}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-06-16 13:20:14 -07:00
|
|
|
} else if (size === 1 && status.getIn(['media_attachments', 0, 'type']) === 'audio' && status.get('media_attachments').size === 1) {
|
2021-10-04 22:44:49 -07:00
|
|
|
const attachment = status.getIn(['media_attachments', 0]);
|
2020-06-24 19:53:25 -07:00
|
|
|
|
|
|
|
media = (
|
|
|
|
<Audio
|
2021-10-04 22:44:49 -07:00
|
|
|
src={attachment.get('url')}
|
|
|
|
alt={attachment.get('description')}
|
|
|
|
duration={attachment.getIn(['meta', 'original', 'duration'], 0)}
|
|
|
|
poster={attachment.get('preview_url') !== attachment.get('url') ? attachment.get('preview_url') : status.getIn(['account', 'avatar_static'])}
|
|
|
|
backgroundColor={attachment.getIn(['meta', 'colors', 'background'])}
|
|
|
|
foregroundColor={attachment.getIn(['meta', 'colors', 'foreground'])}
|
|
|
|
accentColor={attachment.getIn(['meta', 'colors', 'accent'])}
|
|
|
|
height={150}
|
2020-06-24 19:53:25 -07:00
|
|
|
/>
|
|
|
|
);
|
2020-03-27 13:59:38 -07:00
|
|
|
} else {
|
|
|
|
media = (
|
|
|
|
<MediaGallery
|
|
|
|
standalone
|
|
|
|
sensitive={status.get('sensitive')}
|
|
|
|
media={status.get('media_attachments')}
|
|
|
|
height={300}
|
|
|
|
onOpenMedia={this.props.onOpenMedia}
|
|
|
|
visible={this.props.showMedia}
|
|
|
|
onToggleVisibility={this.props.onToggleMediaVisibility}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-01-24 07:52:15 -08:00
|
|
|
} else if (status.get('spoiler_text').length === 0 && !status.get('quote')) {
|
2020-03-27 13:59:38 -07:00
|
|
|
media = <Card onOpenMedia={this.props.onOpenMedia} card={status.get('card', null)} />;
|
|
|
|
}
|
|
|
|
|
2022-01-23 08:55:03 -08:00
|
|
|
let quote;
|
|
|
|
|
2022-01-24 07:52:15 -08:00
|
|
|
if (status.get('quote')) {
|
2022-01-27 08:26:39 -08:00
|
|
|
if (status.getIn(['pleroma', 'quote_visible'], true) === false) {
|
|
|
|
quote = (
|
|
|
|
<div className='quoted-status-tombstone'>
|
|
|
|
<p><FormattedMessage id='statuses.quote_tombstone' defaultMessage='Post is unavailable.' /></p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
quote = <QuotedStatus statusId={status.get('quote')} />;
|
|
|
|
}
|
2022-01-23 08:55:03 -08:00
|
|
|
}
|
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
if (status.get('visibility') === 'direct') {
|
2021-10-14 12:14:13 -07:00
|
|
|
statusTypeIcon = <Icon src={require('@tabler/icons/icons/mail.svg')} />;
|
2020-03-27 13:59:38 -07:00
|
|
|
} else if (status.get('visibility') === 'private') {
|
2021-10-14 12:14:13 -07:00
|
|
|
statusTypeIcon = <Icon src={require('@tabler/icons/icons/lock.svg')} />;
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={outerStyle}>
|
|
|
|
<div ref={this.setRef} className={classNames('detailed-status', { compact })}>
|
2022-03-21 11:09:01 -07:00
|
|
|
<div className='mb-4'>
|
|
|
|
<AccountContainer
|
|
|
|
key={status.getIn(['account', 'id'])}
|
|
|
|
id={status.getIn(['account', 'id'])}
|
|
|
|
timestamp={status.get('created_at')}
|
|
|
|
avatarSize={42}
|
|
|
|
hideActions
|
|
|
|
/>
|
2020-09-11 10:17:32 -07:00
|
|
|
</div>
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
{status.get('group') && (
|
|
|
|
<div className='status__meta'>
|
|
|
|
Posted in <NavLink to={`/groups/${status.getIn(['group', 'id'])}`}>{status.getIn(['group', 'title'])}</NavLink>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2022-01-04 12:06:08 -08:00
|
|
|
<StatusReplyMentions status={status} />
|
|
|
|
|
2021-06-30 19:39:27 -07:00
|
|
|
<StatusContent
|
|
|
|
status={status}
|
|
|
|
expanded={!status.get('hidden')}
|
|
|
|
onExpandedToggle={this.handleExpandedToggle}
|
|
|
|
/>
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
{media}
|
2022-01-23 08:55:03 -08:00
|
|
|
{quote}
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2022-03-21 11:09:01 -07:00
|
|
|
<HStack justifyContent='between' alignItems='center' className='py-2'>
|
2020-05-20 12:44:23 -07:00
|
|
|
<StatusInteractionBar status={status} />
|
2021-10-14 12:14:13 -07:00
|
|
|
|
|
|
|
<div className='detailed-status__timestamp'>
|
2020-09-02 20:38:04 -07:00
|
|
|
{favicon &&
|
2020-09-02 18:49:40 -07:00
|
|
|
<div className='status__favicon'>
|
2020-12-24 14:57:53 -08:00
|
|
|
<Link to={`/timeline/${domain}`}>
|
|
|
|
<img src={favicon} alt='' title={domain} />
|
|
|
|
</Link>
|
2020-09-02 18:49:40 -07:00
|
|
|
</div>}
|
|
|
|
|
2021-10-14 12:14:13 -07:00
|
|
|
{statusTypeIcon}
|
|
|
|
|
2022-03-21 11:09:01 -07:00
|
|
|
<a href={status.get('url')} target='_blank' rel='noopener' className='hover:underline'>
|
|
|
|
<Text tag='span' theme='muted' size='sm'>
|
|
|
|
<FormattedDate value={new Date(status.get('created_at'))} hour12={false} year='numeric' month='short' day='2-digit' hour='2-digit' minute='2-digit' />
|
|
|
|
</Text>
|
2020-05-20 12:44:23 -07:00
|
|
|
</a>
|
|
|
|
</div>
|
2022-03-21 11:09:01 -07:00
|
|
|
</HStack>
|
2020-03-27 13:59:38 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|