QuotedStatus: use StatusMedia component
This commit is contained in:
parent
e1a0759c3a
commit
fb9acf4d64
|
@ -21,7 +21,7 @@ interface IStatusMedia {
|
||||||
/** Whether or not the media is concealed behind a NSFW banner. */
|
/** Whether or not the media is concealed behind a NSFW banner. */
|
||||||
showMedia?: boolean,
|
showMedia?: boolean,
|
||||||
/** Callback when visibility is toggled (eg clicked through NSFW). */
|
/** Callback when visibility is toggled (eg clicked through NSFW). */
|
||||||
onToggleVisibility: () => void,
|
onToggleVisibility?: () => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Render media attachments for a status. */
|
/** Render media attachments for a status. */
|
||||||
|
@ -30,7 +30,7 @@ const StatusMedia: React.FC<IStatusMedia> = ({
|
||||||
muted = false,
|
muted = false,
|
||||||
onClick,
|
onClick,
|
||||||
showMedia = true,
|
showMedia = true,
|
||||||
onToggleVisibility,
|
onToggleVisibility = () => {},
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const [mediaWrapperWidth, setMediaWrapperWidth] = useState<number | undefined>(undefined);
|
const [mediaWrapperWidth, setMediaWrapperWidth] = useState<number | undefined>(undefined);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { defineMessages, injectIntl, FormattedMessage, IntlShape, FormattedList
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import AttachmentThumbs from 'soapbox/components/attachment-thumbs';
|
import AttachmentThumbs from 'soapbox/components/attachment-thumbs';
|
||||||
|
import StatusMedia from 'soapbox/components/status-media';
|
||||||
import { Stack, Text } from 'soapbox/components/ui';
|
import { Stack, Text } from 'soapbox/components/ui';
|
||||||
import AccountContainer from 'soapbox/containers/account_container';
|
import AccountContainer from 'soapbox/containers/account_container';
|
||||||
|
|
||||||
|
@ -50,6 +51,25 @@ class QuotedStatus extends ImmutablePureComponent<IQuotedStatus> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderMedia = () => {
|
||||||
|
const { status } = this.props;
|
||||||
|
if (!status) return null;
|
||||||
|
const { size } = status.media_attachments;
|
||||||
|
|
||||||
|
if (size > 1) {
|
||||||
|
return (
|
||||||
|
<AttachmentThumbs
|
||||||
|
media={status.media_attachments}
|
||||||
|
sensitive={status.sensitive}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StatusMedia status={status} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
renderReplyMentions = () => {
|
renderReplyMentions = () => {
|
||||||
const { status } = this.props;
|
const { status } = this.props;
|
||||||
|
|
||||||
|
@ -147,12 +167,7 @@ class QuotedStatus extends ImmutablePureComponent<IQuotedStatus> {
|
||||||
dangerouslySetInnerHTML={{ __html: status.contentHtml }}
|
dangerouslySetInnerHTML={{ __html: status.contentHtml }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{status.media_attachments.size > 0 && (
|
{this.renderMedia()}
|
||||||
<AttachmentThumbs
|
|
||||||
media={status.media_attachments}
|
|
||||||
sensitive={status.sensitive}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue