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-02-21 00:56:31 -08:00
|
|
|
import { injectIntl } from 'react-intl';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { connect } from 'react-redux';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:17:52 -08:00
|
|
|
import StatusContent from 'soapbox/components/status_content';
|
2022-02-21 00:56:31 -08:00
|
|
|
import StatusReplyMentions from 'soapbox/components/status_reply_mentions';
|
2022-04-18 11:42:48 -07:00
|
|
|
import { HStack } from 'soapbox/components/ui';
|
|
|
|
import AccountContainer from 'soapbox/containers/account_container';
|
2021-11-15 19:58:30 -08:00
|
|
|
import PlaceholderCard from 'soapbox/features/placeholder/components/placeholder_card';
|
2022-01-26 10:28:01 -08:00
|
|
|
import PlaceholderMediaGallery from 'soapbox/features/placeholder/components/placeholder_media_gallery';
|
|
|
|
import QuotedStatus from 'soapbox/features/status/containers/quoted_status_container';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
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)
|
2022-01-14 13:35:28 -08:00
|
|
|
@injectIntl
|
2021-10-09 14:56:03 -07:00
|
|
|
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')}
|
|
|
|
/>
|
|
|
|
);
|
2022-01-26 10:49:04 -08:00
|
|
|
} else if (!status.get('quote') && shouldHaveCard(status)) {
|
2021-11-15 19:58:30 -08:00
|
|
|
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;
|
|
|
|
|
|
|
|
return (
|
2022-04-18 11:42:48 -07:00
|
|
|
<div className={classNames('opacity-50', className)}>
|
|
|
|
<div className={classNames('status', { 'status-reply': !!status.get('in_reply_to_id'), muted: this.props.muted })} data-id={status.get('id')}>
|
|
|
|
<div className={classNames('status__wrapper', `status-${status.get('visibility')}`, { 'status-reply': !!status.get('in_reply_to_id') })} tabIndex={this.props.muted ? null : 0}>
|
|
|
|
<div className='mb-4'>
|
|
|
|
<HStack justifyContent='between' alignItems='start'>
|
|
|
|
<AccountContainer
|
|
|
|
key={String(status.getIn(['account', 'id']))}
|
|
|
|
id={String(status.getIn(['account', 'id']))}
|
|
|
|
timestamp={status.created_at}
|
|
|
|
timestampUrl={status.get('created_at')}
|
|
|
|
hideActions
|
|
|
|
/>
|
|
|
|
</HStack>
|
2021-10-09 14:56:03 -07:00
|
|
|
</div>
|
|
|
|
|
2022-04-18 11:42:48 -07:00
|
|
|
<div className='status__content-wrapper'>
|
|
|
|
<StatusReplyMentions status={status} />
|
2022-01-14 13:35:28 -08:00
|
|
|
|
2022-04-18 11:42:48 -07:00
|
|
|
<StatusContent
|
|
|
|
status={status}
|
|
|
|
expanded
|
|
|
|
collapsable
|
|
|
|
/>
|
2021-10-09 14:56:03 -07:00
|
|
|
|
2022-04-18 11:42:48 -07:00
|
|
|
{this.renderMedia()}
|
|
|
|
{status.get('poll') && <PollPreview poll={status.get('poll')} />}
|
2021-10-09 14:56:03 -07:00
|
|
|
|
2022-04-18 11:42:48 -07:00
|
|
|
{status.get('quote') && <QuotedStatus statusId={status.get('quote')} />}
|
|
|
|
</div>
|
2022-01-26 10:28:01 -08:00
|
|
|
|
2021-10-09 14:56:03 -07:00
|
|
|
{/* TODO */}
|
|
|
|
{/* <PlaceholderActionBar /> */}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|