import React, { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { Link } from 'react-router-dom'; import { changeSetting } from 'soapbox/actions/settings'; import { connectPublicStream } from 'soapbox/actions/streaming'; import { expandPublicTimeline } from 'soapbox/actions/timelines'; import PullToRefresh from 'soapbox/components/pull-to-refresh'; import { Accordion, Column } from 'soapbox/components/ui'; import { useAppDispatch, useInstance, useSettings } from 'soapbox/hooks'; import PinnedHostsPicker from '../remote-timeline/components/pinned-hosts-picker'; import Timeline from '../ui/components/timeline'; const messages = defineMessages({ title: { id: 'column.public', defaultMessage: 'Fediverse timeline' }, dismiss: { id: 'fediverse_tab.explanation_box.dismiss', defaultMessage: 'Don\'t show again' }, }); const CommunityTimeline = () => { const intl = useIntl(); const dispatch = useAppDispatch(); const instance = useInstance(); const settings = useSettings(); const onlyMedia = settings.getIn(['public', 'other', 'onlyMedia']); const timelineId = 'public'; const explanationBoxExpanded = settings.get('explanationBox'); const showExplanationBox = settings.get('showExplanationBox'); const explanationBoxMenu = () => { return [{ text: intl.formatMessage(messages.dismiss), action: dismissExplanationBox }]; }; const dismissExplanationBox = () => { dispatch(changeSetting(['showExplanationBox'], false)); }; const toggleExplanationBox = (setting: boolean) => { dispatch(changeSetting(['explanationBox'], setting)); }; const handleLoadMore = (maxId: string) => { dispatch(expandPublicTimeline({ maxId, onlyMedia })); }; const handleRefresh = () => { return dispatch(expandPublicTimeline({ onlyMedia } as any)); }; useEffect(() => { dispatch(expandPublicTimeline({ onlyMedia } as any)); const disconnect = dispatch(connectPublicStream({ onlyMedia })); return () => { disconnect(); }; }, [onlyMedia]); return ( {showExplanationBox &&
} menu={explanationBoxMenu()} expanded={explanationBoxExpanded} onToggle={toggleExplanationBox} > ), }} />
} } divideType='space' />
); }; export default CommunityTimeline;