2022-09-13 01:21:56 -07:00
|
|
|
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';
|
|
|
|
|
2022-09-10 14:52:06 -07:00
|
|
|
interface IQuotedStatusContainer {
|
|
|
|
composeId: string,
|
|
|
|
}
|
|
|
|
|
2022-06-07 12:48:24 -07:00
|
|
|
/** QuotedStatus shown in post composer. */
|
2022-09-10 14:52:06 -07:00
|
|
|
const QuotedStatusContainer: React.FC<IQuotedStatusContainer> = ({ composeId }) => {
|
2022-06-07 12:48:24 -07:00
|
|
|
const dispatch = useAppDispatch();
|
2022-09-13 01:21:56 -07:00
|
|
|
const getStatus = useCallback(makeGetStatus(), []);
|
2022-10-11 11:22:54 -07:00
|
|
|
|
2022-09-14 11:01:00 -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;
|