import { FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import type { Map as ImmutableMap } from 'immutable';
import { Icon } from 'mastodon/components/icon';
import StatusContainer from 'mastodon/containers/status_container';
import { useAppSelector } from 'mastodon/store';
import QuoteIcon from '../../images/quote.svg?react';
const QuoteWrapper: React.FC<{
isError?: boolean;
children: React.ReactNode;
}> = ({ isError, children }) => {
return (
{children}
);
};
type QuoteMap = ImmutableMap<'state' | 'quoted_status', string | null>;
export const QuotedStatus: React.FC<{ quote: QuoteMap }> = ({ quote }) => {
const quotedStatusId = quote.get('quoted_status');
const state = quote.get('state');
const status = useAppSelector((state) =>
quotedStatusId ? state.statuses.get(quotedStatusId) : undefined,
);
let quoteError: React.ReactNode | null = null;
if (state === 'deleted') {
quoteError = (
);
} else if (state === 'unauthorized') {
quoteError = (
);
} else if (state === 'pending') {
quoteError = (
);
} else if (state === 'rejected' || state === 'revoked') {
quoteError = (
);
} else if (!status || !quotedStatusId) {
quoteError = (
);
}
if (quoteError) {
return {quoteError};
}
return (
);
};
interface StatusQuoteManagerProps {
id: string;
[key: string]: unknown;
}
/**
* This wrapper component takes a status ID and, if the associated status
* is a quote post, it renders the quote into `StatusContainer` as a child.
* It passes all other props through to `StatusContainer`.
*/
export const StatusQuoteManager = (props: StatusQuoteManagerProps) => {
const status = useAppSelector((state) => state.statuses.get(props.id));
const quote = status?.get('quote') as QuoteMap | undefined;
if (quote) {
return (
);
}
return ;
};