import React, { useEffect, useState } from 'react'; import { fetchStatus } from 'soapbox/actions/statuses'; import MissingIndicator from 'soapbox/components/missing_indicator'; import Status from 'soapbox/components/status'; import { Spinner } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { makeGetStatus } from 'soapbox/selectors'; interface IEmbeddedStatus { params: { statusId: string, }, } const getStatus = makeGetStatus(); /** Status to be presented in an iframe for embeds on external websites. */ const EmbeddedStatus: React.FC = ({ params }) => { const dispatch = useAppDispatch(); const status = useAppSelector(state => getStatus(state, { id: params.statusId })); const [loading, setLoading] = useState(true); useEffect(() => { dispatch(fetchStatus(params.statusId)) .then(() => setLoading(false)) .catch(() => setLoading(false)); }, []); const renderInner = () => { if (loading) { return ; } else if (status) { return ; } else { return ; } }; return (
{renderInner()}
); }; export default EmbeddedStatus;