File size: 1,417 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import { Button } from '@automattic/components';
import { useTranslate } from 'i18n-calypso';
import { useDispatch, useSelector } from 'react-redux';
import SectionHeader from 'calypso/components/section-header';
import Stream from 'calypso/reader/stream';
import { recordReaderTracksEvent } from 'calypso/state/reader/analytics/actions';
import { P2_ORG_ID } from 'calypso/state/reader/organizations/constants';
import { getReaderOrganizationFeedsInfo } from 'calypso/state/reader/organizations/selectors';
import { requestMarkAllAsSeen } from 'calypso/state/reader/seen-posts/actions';
import { SECTION_P2_FOLLOWING } from 'calypso/state/reader/seen-posts/constants';
export default function P2Following( props ) {
const translate = useTranslate();
const dispatch = useDispatch();
const feedsInfo = useSelector( ( state ) => getReaderOrganizationFeedsInfo( state, P2_ORG_ID ) );
const markAllAsSeen = () => {
const { feedIds, feedUrls } = feedsInfo;
dispatch( recordReaderTracksEvent( 'calypso_reader_mark_all_as_seen_clicked' ) );
dispatch( requestMarkAllAsSeen( { identifier: SECTION_P2_FOLLOWING, feedIds, feedUrls } ) );
};
return (
<Stream { ...props }>
<SectionHeader label={ translate( 'Followed P2 Sites' ) }>
<Button compact onClick={ markAllAsSeen } disabled={ ! feedsInfo.unseenCount }>
{ translate( 'Mark all as seen' ) }
</Button>
</SectionHeader>
</Stream>
);
}
|