import Icon from '@components/Icon' import { displayMessage } from '@components/Message' import { ParseEmojis } from '@components/Parse' import CustomText from '@components/Text' import { useTimelineMutation } from '@utils/queryHooks/timeline' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useContext } from 'react' import { useTranslation } from 'react-i18next' import { Pressable, View } from 'react-native' import { useQueryClient } from 'react-query' import StatusContext from './Context' import HeaderSharedCreated from './HeaderShared/Created' import HeaderSharedMuted from './HeaderShared/Muted' export interface Props { conversation: Mastodon.Conversation } const HeaderConversation = ({ conversation }: Props) => { const { queryKey } = useContext(StatusContext) if (!queryKey) return null const { colors, theme } = useTheme() const { t } = useTranslation('componentTimeline') const queryClient = useQueryClient() const mutation = useTimelineMutation({ onMutate: true, onError: (err: any, _, oldData) => { displayMessage({ theme, type: 'error', message: t('common:message.error.message', { function: t(`shared.header.conversation.delete.function`) }), ...(err.status && typeof err.status === 'number' && err.data && err.data.error && typeof err.data.error === 'string' && { description: err.data.error }) }) queryClient.setQueryData(queryKey, oldData) } }) return ( {t('shared.header.conversation.withAccounts')} {conversation.accounts.map((account, index) => ( {index !== 0 ? t('common:separator') : undefined} ))} {conversation.last_status?.created_at ? ( ) : null} mutation.mutate({ type: 'deleteItem', source: 'conversations', queryKey, id: conversation.id }) } children={} /> ) } export default HeaderConversation