import React, { useEffect } from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import { groupCompose } from 'soapbox/actions/compose'; import { connectGroupStream } from 'soapbox/actions/streaming'; import { expandGroupTimeline } from 'soapbox/actions/timelines'; import { Avatar, HStack, Icon, Stack, Text } from 'soapbox/components/ui'; import ComposeForm from 'soapbox/features/compose/components/compose-form'; import { useAppDispatch, useGroup, useOwnAccount } from 'soapbox/hooks'; import Timeline from '../ui/components/timeline'; type RouteParams = { id: string }; interface IGroupTimeline { params: RouteParams } const GroupTimeline: React.FC = (props) => { const account = useOwnAccount(); const dispatch = useAppDispatch(); const groupId = props.params.id; const { group } = useGroup(groupId); const canComposeGroupStatus = !!account && group?.relationship?.member; const handleLoadMore = (maxId: string) => { dispatch(expandGroupTimeline(groupId, { maxId })); }; useEffect(() => { dispatch(expandGroupTimeline(groupId)); dispatch(groupCompose(`group:${groupId}`, groupId)); const disconnect = dispatch(connectGroupStream(groupId)); return () => { disconnect(); }; }, [groupId]); if (!group) { return null; } return ( {canComposeGroupStatus && (
)}
} emptyMessageCard={false} divideType='border' showGroup={false} /> ); }; export default GroupTimeline;