2022-01-10 14:17:52 -08:00
|
|
|
import classNames from 'classnames';
|
2021-10-09 14:56:03 -07:00
|
|
|
import React from 'react';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { connect } from 'react-redux';
|
2021-10-09 14:56:03 -07:00
|
|
|
import { Link, NavLink } from 'react-router-dom';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-10-09 14:56:03 -07:00
|
|
|
import Avatar from 'soapbox/components/avatar';
|
|
|
|
import DisplayName from 'soapbox/components/display_name';
|
2022-01-10 14:17:52 -08:00
|
|
|
import RelativeTimestamp from 'soapbox/components/relative_timestamp';
|
|
|
|
import StatusContent from 'soapbox/components/status_content';
|
2021-11-15 19:58:30 -08:00
|
|
|
import PlaceholderCard from 'soapbox/features/placeholder/components/placeholder_card';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { getDomain } from 'soapbox/utils/accounts';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-12-18 07:26:26 -08:00
|
|
|
import PlaceholderMediaGallery from '../../placeholder/components/placeholder_media_gallery';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { buildStatus } from '../util/pending_status_builder';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import PollPreview from './poll_preview';
|
2021-11-15 19:58:30 -08:00
|
|
|
|
|
|
|
const shouldHaveCard = pendingStatus => {
|
|
|
|
return Boolean(pendingStatus.get('content').match(/https?:\/\/\S*/));
|
|
|
|
};
|
2021-10-09 14:56:03 -07:00
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => {
|
|
|
|
const { idempotencyKey } = props;
|
|
|
|
const pendingStatus = state.getIn(['pending_statuses', idempotencyKey]);
|
|
|
|
return {
|
|
|
|
status: pendingStatus ? buildStatus(state, pendingStatus, idempotencyKey) : null,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
class PendingStatus extends ImmutablePureComponent {
|
|
|
|
|
2021-11-15 19:58:30 -08:00
|
|
|
renderMedia = () => {
|
|
|
|
const { status } = this.props;
|
|
|
|
|
|
|
|
if (status.get('media_attachments') && !status.get('media_attachments').isEmpty()) {
|
|
|
|
return (
|
2021-12-18 07:26:26 -08:00
|
|
|
<PlaceholderMediaGallery
|
2021-11-15 19:58:30 -08:00
|
|
|
media={status.get('media_attachments')}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
} else if (shouldHaveCard(status)) {
|
|
|
|
return <PlaceholderCard />;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-09 14:56:03 -07:00
|
|
|
render() {
|
2022-01-04 18:28:49 -08:00
|
|
|
const { status, className } = this.props;
|
2021-10-09 14:56:03 -07:00
|
|
|
if (!status) return null;
|
|
|
|
if (!status.get('account')) return null;
|
|
|
|
|
|
|
|
const favicon = status.getIn(['account', 'pleroma', 'favicon']);
|
|
|
|
const domain = getDomain(status.get('account'));
|
|
|
|
|
|
|
|
return (
|
2021-10-09 19:39:15 -07:00
|
|
|
<div className={classNames('pending-status', className)}>
|
2021-10-09 14:56:03 -07:00
|
|
|
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility')}`, { 'status__wrapper-reply': !!status.get('in_reply_to_id') })} tabIndex={this.props.muted ? null : 0}>
|
|
|
|
<div className={classNames('status', `status-${status.get('visibility')}`, { 'status-reply': !!status.get('in_reply_to_id'), muted: this.props.muted })} data-id={status.get('id')}>
|
|
|
|
<div className='status__expand' onClick={this.handleExpandClick} role='presentation' />
|
|
|
|
<div className='status__info'>
|
|
|
|
<span className='status__relative-time'>
|
|
|
|
<RelativeTimestamp timestamp={status.get('created_at')} />
|
|
|
|
</span>
|
|
|
|
|
|
|
|
{favicon &&
|
|
|
|
<div className='status__favicon'>
|
|
|
|
<Link to={`/timeline/${domain}`}>
|
|
|
|
<img src={favicon} alt='' title={domain} />
|
|
|
|
</Link>
|
|
|
|
</div>}
|
|
|
|
|
|
|
|
<div className='status__profile'>
|
|
|
|
<div className='status__avatar'>
|
|
|
|
<NavLink to={`/@${status.getIn(['account', 'acct'])}`} title={status.getIn(['account', 'acct'])}>
|
|
|
|
<Avatar account={status.get('account')} size={48} />
|
|
|
|
</NavLink>
|
|
|
|
</div>
|
|
|
|
<NavLink to={`/@${status.getIn(['account', 'acct'])}`} title={status.getIn(['account', 'acct'])} className='status__display-name'>
|
|
|
|
<DisplayName account={status.get('account')} />
|
|
|
|
</NavLink>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<StatusContent
|
|
|
|
status={status}
|
|
|
|
expanded
|
|
|
|
collapsable
|
|
|
|
/>
|
|
|
|
|
2021-11-15 19:58:30 -08:00
|
|
|
{this.renderMedia()}
|
2021-10-09 14:56:03 -07:00
|
|
|
{status.get('poll') && <PollPreview poll={status.get('poll')} />}
|
|
|
|
|
|
|
|
{/* TODO */}
|
|
|
|
{/* <PlaceholderActionBar /> */}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|