import PropTypes from 'prop-types'; import { useRef, useCallback, useEffect } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { Helmet } from 'react-helmet'; import { useDispatch } from 'react-redux'; import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react'; import { addColumn, removeColumn, moveColumn } from 'mastodon/actions/columns'; import { mountConversations, unmountConversations, expandConversations } from 'mastodon/actions/conversations'; import { connectDirectStream } from 'mastodon/actions/streaming'; import Column from 'mastodon/components/column'; import ColumnHeader from 'mastodon/components/column_header'; import { ConversationsList } from './components/conversations_list'; const messages = defineMessages({ title: { id: 'column.direct', defaultMessage: 'Private mentions' }, }); const DirectTimeline = ({ columnId, multiColumn }) => { const columnRef = useRef(); const intl = useIntl(); const dispatch = useDispatch(); const pinned = !!columnId; const handlePin = useCallback(() => { if (columnId) { dispatch(removeColumn(columnId)); } else { dispatch(addColumn('DIRECT', {})); } }, [dispatch, columnId]); const handleMove = useCallback((dir) => { dispatch(moveColumn(columnId, dir)); }, [dispatch, columnId]); const handleHeaderClick = useCallback(() => { columnRef.current.scrollTop(); }, [columnRef]); useEffect(() => { dispatch(mountConversations()); dispatch(expandConversations()); const disconnect = dispatch(connectDirectStream()); return () => { dispatch(unmountConversations()); disconnect(); }; }, [dispatch]); return ( } bindToDocument={!multiColumn} prepend={
} alwaysPrepend /> {intl.formatMessage(messages.title)}
); }; DirectTimeline.propTypes = { columnId: PropTypes.string, multiColumn: PropTypes.bool, }; export default DirectTimeline;