import clsx from 'clsx'; import { List as ImmutableList } from 'immutable'; import React, { useEffect } from 'react'; import { FormattedDate, FormattedMessage } from 'react-intl'; import { fetchHistory } from 'soapbox/actions/history'; import AttachmentThumbs from 'soapbox/components/attachment-thumbs'; import { HStack, Modal, Spinner, Stack, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import type { StatusEdit as StatusEditEntity } from 'soapbox/types/entities'; interface ICompareHistoryModal { onClose: (string: string) => void statusId: string } const CompareHistoryModal: React.FC = ({ onClose, statusId }) => { const dispatch = useAppDispatch(); const loading = useAppSelector(state => state.history.getIn([statusId, 'loading'])); // @ts-ignore const versions = useAppSelector>(state => state.history.getIn([statusId, 'items'])); const onClickClose = () => { onClose('COMPARE_HISTORY'); }; useEffect(() => { dispatch(fetchHistory(statusId)); }, [statusId]); let body; if (loading) { body = ; } else { body = (
{versions?.map((version) => { const content = { __html: version.contentHtml }; const spoilerContent = { __html: version.spoilerHtml }; const poll = typeof version.poll !== 'string' && version.poll; return (
{version.spoiler_text?.length > 0 && ( <>
)}
{poll && (
{version.poll.options.map((option: any) => ( ))}
)} {version.media_attachments.size > 0 && ( )}
); })}
); } return ( } onClose={onClickClose} > {body} ); }; export default CompareHistoryModal;