PendingStatus: display PlaceholderCard when a card is expected

features-override
Alex Gleason 2021-11-15 21:58:30 -06:00
rodzic 1714ac03d2
commit a3ce7b2afe
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 23 dodań i 5 usunięć

Wyświetl plik

@ -12,6 +12,11 @@ import Avatar from 'soapbox/components/avatar';
import DisplayName from 'soapbox/components/display_name';
import AttachmentThumbs from 'soapbox/components/attachment_thumbs';
import PollPreview from './poll_preview';
import PlaceholderCard from 'soapbox/features/placeholder/components/placeholder_card';
const shouldHaveCard = pendingStatus => {
return Boolean(pendingStatus.get('content').match(/https?:\/\/\S*/));
};
const mapStateToProps = (state, props) => {
const { idempotencyKey } = props;
@ -24,6 +29,23 @@ const mapStateToProps = (state, props) => {
export default @connect(mapStateToProps)
class PendingStatus extends ImmutablePureComponent {
renderMedia = () => {
const { status } = this.props;
if (status.get('media_attachments') && !status.get('media_attachments').isEmpty()) {
return (
<AttachmentThumbs
compact
media={status.get('media_attachments')}
/>
);
} else if (shouldHaveCard(status)) {
return <PlaceholderCard />;
} else {
return null;
}
}
render() {
const { status, className, showThread } = this.props;
if (!status) return null;
@ -67,11 +89,7 @@ class PendingStatus extends ImmutablePureComponent {
collapsable
/>
<AttachmentThumbs
compact
media={status.get('media_attachments')}
/>
{this.renderMedia()}
{status.get('poll') && <PollPreview poll={status.get('poll')} />}
{showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) && (