import { useCallback, useState } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import classNames from 'classnames'; import RepeatIcon from '@/material-icons/400-24px/repeat.svg?react'; import { Button } from 'mastodon/components/button'; import { Icon } from 'mastodon/components/icon'; import PrivacyDropdown from 'mastodon/features/compose/components/privacy_dropdown'; import { EmbeddedStatus } from 'mastodon/features/notifications_v2/components/embedded_status'; import type { Status, StatusVisibility } from 'mastodon/models/status'; import { useAppSelector } from 'mastodon/store'; const messages = defineMessages({ cancel_reblog: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost', }, reblog: { id: 'status.reblog', defaultMessage: 'Boost' }, }); export const BoostModal: React.FC<{ status: Status; onClose: () => void; onReblog: (status: Status, privacy: StatusVisibility) => void; }> = ({ status, onReblog, onClose }) => { const intl = useIntl(); const defaultPrivacy = useAppSelector( // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access (state) => state.compose.get('default_privacy') as StatusVisibility, ); const statusId = status.get('id') as string; const statusVisibility = status.get('visibility') as StatusVisibility; const [privacy, setPrivacy] = useState( statusVisibility === 'private' ? 'private' : defaultPrivacy, ); const onPrivacyChange = useCallback((value: StatusVisibility) => { setPrivacy(value); }, []); const handleReblog = useCallback(() => { onReblog(status, privacy); onClose(); }, [onClose, onReblog, status, privacy]); const handleCancel = useCallback(() => { onClose(); }, [onClose]); const findContainer = useCallback( () => document.getElementsByClassName('modal-root__container')[0], [], ); return (

{status.get('reblogged') ? ( ) : ( )}

Shift+ ), }} />
{!status.get('reblogged') && ( )}
); };