import ComponentAccount from '@components/Account' import { HeaderLeft, HeaderRight } from '@components/Header' import Icon from '@components/Icon' import { displayMessage } from '@components/Message' import { ModalScrollView } from '@components/ModalScrollView' import Selections from '@components/Selections' import CustomText from '@components/Text' import { TabSharedStackScreenProps } from '@utils/navigation/navigators' import { useTimelineMutation } from '@utils/queryHooks/timeline' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { Pressable, View } from 'react-native' const TabSharedMute: React.FC> = ({ navigation, route: { params: { account } } }) => { const { colors, theme } = useTheme() const { t } = useTranslation(['common', 'screenTabs']) const { mutateAsync, isLoading } = useTimelineMutation({ onSuccess: () => displayMessage({ type: 'success', message: t('common:message.success.message', { function: t('componentContextMenu:account.mute.action', { defaultValue: 'false', context: 'false' }) }) }) }) const [durations, setDurations] = useState<{ selected: boolean; content: string }[]>( (['0', '1800', '3600', '86400', '604800'] as ['0', '1800', '3600', '86400', '604800']).map( duration => ({ selected: duration === '0', content: t(`screenTabs:shared.mute.duration.${duration}`) }) ) ) const [notification, setNotification] = useState(false) useEffect(() => { navigation.setOptions({ title: t('screenTabs:shared.mute.name', { acct: `@${account.acct}` }), headerLeft: () => ( navigation.goBack()} /> ), headerRight: () => ( { await mutateAsync({ type: 'updateAccountProperty', id: account.id, payload: { property: 'mute', currentValue: false } }) navigation.pop(1) }} loading={isLoading} /> ) }) }, [theme, isLoading, durations, notification, account.id]) return ( {t('screenTabs:shared.mute.description')} setNotification(!notification)} > {t('screenTabs:shared.mute.notification')} ) } export default TabSharedMute