import React, { useEffect } from 'react'; import { FormattedDate, FormattedMessage } from 'react-intl'; import { fetchHistory } from 'soapbox/actions/history'; import { Modal, Spinner, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; 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'])); 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: any) => { const content = { __html: version.contentHtml }; const spoilerContent = { __html: version.spoilerHtml }; return (
{version.spoiler_text?.length > 0 && ( <>
)}
); })}
); } return ( } onClose={onClickClose} > {body} ); }; export default CompareHistoryModal;