import React from 'react'; import { FormattedMessage } from 'react-intl'; import Toggle from 'react-toggle'; import { muteAccount } from 'soapbox/actions/accounts'; import { closeModal } from 'soapbox/actions/modals'; import { toggleHideNotifications, changeMuteDuration } from 'soapbox/actions/mutes'; import { Modal, HStack, Stack, Text } from 'soapbox/components/ui'; import DurationSelector from 'soapbox/features/compose/components/polls/duration-selector'; import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; const getAccount = makeGetAccount(); const MuteModal = () => { const dispatch = useAppDispatch(); const account = useAppSelector((state) => getAccount(state, state.mutes.new.accountId!)); const notifications = useAppSelector((state) => state.mutes.new.notifications); const duration = useAppSelector((state) => state.mutes.new.duration); const mutesDuration = useFeatures().mutesDuration; if (!account) return null; const handleClick = () => { dispatch(closeModal()); dispatch(muteAccount(account.id, notifications, duration)); }; const handleCancel = () => { dispatch(closeModal()); }; const toggleNotifications = () => { dispatch(toggleHideNotifications()); }; const handleChangeMuteDuration = (expiresIn: number): void => { dispatch(changeMuteDuration(expiresIn)); }; const toggleAutoExpire = () => handleChangeMuteDuration(duration ? 0 : 2 * 60 * 60 * 24); return ( } onClose={handleCancel} confirmationAction={handleClick} confirmationText={} cancelText={} cancelAction={handleCancel} > @{account.acct} }} /> {mutesDuration && ( <> {duration !== 0 && ( : )} )} ); }; export default MuteModal;