File size: 2,134 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import { NoticeBanner } from '@automattic/components';
import { ExternalLink } from '@wordpress/components';
import { useEffect } from '@wordpress/element';
import { useTranslate } from 'i18n-calypso';
import QueryPreferences from 'calypso/components/data/query-preferences';
import { useDispatch, useSelector } from 'calypso/state';
import { savePreference } from 'calypso/state/preferences/actions';
import { getPreference } from 'calypso/state/preferences/selectors';
import { recordReaderTracksEvent } from 'calypso/state/reader/analytics/actions';
const ConversationsIntro = ( { isInternal = false } ) => {
const translate = useTranslate();
const dispatch = useDispatch();
const preferenceName = isInternal
? 'has_used_reader_conversations_a8c'
: 'has_used_reader_conversations';
const hasUsedConversations = useSelector( ( state ) => getPreference( state, preferenceName ) );
useEffect( () => {
if ( ! hasUsedConversations ) {
recordReaderTracksEvent( 'calypso_reader_conversations_intro_render' );
}
}, [ hasUsedConversations ] );
if ( hasUsedConversations ) {
return null;
}
const onClose = () => {
recordReaderTracksEvent( 'calypso_reader_conversations_intro_dismiss' );
dispatch( savePreference( preferenceName, true ) );
};
return (
<>
<QueryPreferences />
<NoticeBanner
level="info"
title={
isInternal
? translate( 'Welcome to A8C Conversations.' )
: translate( 'Welcome to Conversations.' )
}
onClose={ onClose }
>
{ isInternal
? translate(
`Automattic P2 posts you've written, followed, or commented on will appear here when they have new comments. ` +
`Posts with the most recent comments appear on top. ` +
`{{a}}More info{{/a}}`,
{
components: {
a: <ExternalLink href="http://wp.me/p5PDj3-44u" />,
},
}
)
: translate(
`WordPress posts you've written, followed, or commented on will appear here when they have new comments. Posts with the most recent comments appear on top.`
) }
</NoticeBanner>
</>
);
};
export default ConversationsIntro;
|