import { MessageMetricsItem, MessageBlock, MessageMetrics, MessageMetricsReply, MessageMetricsFollowing } from '@rocket.chat/fuselage'; import { useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts'; import type { ReactElement } from 'react'; import React, { useCallback } from 'react'; import { useTimeAgo } from '../../../hooks/useTimeAgo'; import { useToggleFollowingThreadMutation } from '../../../views/room/contextualBar/Threads/hooks/useToggleFollowingThreadMutation'; import { useGoToThread } from '../../../views/room/hooks/useGoToThread'; import { followStyle, anchor } from '../helpers/followSyle'; import AllMentionNotification from '../notification/AllMentionNotification'; import MeMentionNotification from '../notification/MeMentionNotification'; import UnreadMessagesNotification from '../notification/UnreadMessagesNotification'; type ThreadMetricsProps = { unread: boolean; mention: boolean; all: boolean; lm: Date; mid: string; rid: string; counter: number; participants: number; following: boolean; }; const ThreadMetrics = ({ unread, mention, all, rid, mid, counter, participants, following, lm }: ThreadMetricsProps): ReactElement => { const t = useTranslation(); const format = useTimeAgo(); const goToThread = useGoToThread(); const dispatchToastMessage = useToastMessageDispatch(); const toggleFollowingThreadMutation = useToggleFollowingThreadMutation({ onError: (error) => { dispatchToastMessage({ type: 'error', message: error }); }, }); const handleFollow = useCallback(() => { toggleFollowingThreadMutation.mutate({ rid, tmid: mid, follow: !following }); }, [following, rid, mid, toggleFollowingThreadMutation]); return ( goToThread({ rid, tmid: mid })}> {t('Reply')} {counter} {!!participants && ( {participants} )} {format(lm)} {(mention || all || unread) && ( {(mention && ) || (all && ) || (unread && )} )} ); }; export default ThreadMetrics;