import classNames from 'classnames'; import React from 'react'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { connect } from 'react-redux'; import { Link, NavLink } from 'react-router-dom'; import Avatar from 'soapbox/components/avatar'; import DisplayName from 'soapbox/components/display_name'; import RelativeTimestamp from 'soapbox/components/relative_timestamp'; import StatusContent from 'soapbox/components/status_content'; import PlaceholderCard from 'soapbox/features/placeholder/components/placeholder_card'; import { getDomain } from 'soapbox/utils/accounts'; import PlaceholderMediaGallery from '../../placeholder/components/placeholder_media_gallery'; import { buildStatus } from '../util/pending_status_builder'; import PollPreview from './poll_preview'; const shouldHaveCard = pendingStatus => { return Boolean(pendingStatus.get('content').match(/https?:\/\/\S*/)); }; 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 { renderMedia = () => { const { status } = this.props; if (status.get('media_attachments') && !status.get('media_attachments').isEmpty()) { return ( ); } else if (shouldHaveCard(status)) { return ; } else { return null; } } render() { const { status, className } = this.props; if (!status) return null; if (!status.get('account')) return null; const favicon = status.getIn(['account', 'pleroma', 'favicon']); const domain = getDomain(status.get('account')); return (
{favicon &&
}
{this.renderMedia()} {status.get('poll') && } {/* TODO */} {/* */}
); } }