bigbuffet-rw/app/soapbox/features/compose/containers/quoted-status-container.tsx

39 lines
972 B
TypeScript
Raw Normal View History

import React, { useCallback } from 'react';
2022-06-07 12:48:24 -07:00
import { cancelQuoteCompose } from 'soapbox/actions/compose';
2022-06-08 09:07:41 -07:00
import QuotedStatus from 'soapbox/components/quoted-status';
2022-06-07 12:48:24 -07:00
import { useAppSelector, useAppDispatch } from 'soapbox/hooks';
import { makeGetStatus } from 'soapbox/selectors';
interface IQuotedStatusContainer {
composeId: string,
}
2022-06-07 12:48:24 -07:00
/** QuotedStatus shown in post composer. */
const QuotedStatusContainer: React.FC<IQuotedStatusContainer> = ({ composeId }) => {
2022-06-07 12:48:24 -07:00
const dispatch = useAppDispatch();
const getStatus = useCallback(makeGetStatus(), []);
2022-10-11 11:22:54 -07:00
const status = useAppSelector(state => getStatus(state, { id: state.compose.get(composeId)?.quote! }));
2022-06-07 12:48:24 -07:00
const onCancel = () => {
dispatch(cancelQuoteCompose());
};
if (!status) {
return null;
}
return (
2022-06-20 10:27:16 -07:00
<div className='mb-2'>
<QuotedStatus
status={status}
onCancel={onCancel}
compose
/>
</div>
2022-06-07 12:48:24 -07:00
);
};
export default QuotedStatusContainer;