import { Component } from 'react'; import { connect } from 'react-redux'; import { recordTracksEvent } from '../helpers/stats'; import { html } from '../indices-to-html'; import actions from '../state/actions'; import noticon2gridicon from '../utils/noticon2gridicon'; import Gridicon from './gridicons'; import ImagePreloader from './image-loader'; export class SummaryInList extends Component { handleClick = ( event ) => { event.stopPropagation(); event.preventDefault(); if ( event.metaKey || event.shiftKey ) { window.open( this.props.note.url, '_blank' ); } else if ( this.props.currentNote === this.props.note.id ) { this.props.unselectNote(); } else { recordTracksEvent( 'calypso_notification_note_open', { note_type: this.props.note.type, } ); this.props.selectNote( this.props.note.id ); } }; render() { const subject = html( this.props.note.subject[ 0 ], { links: false, } ); let excerpt = null; if ( 1 < this.props.note.subject.length ) { excerpt =
{ this.props.note.subject[ 1 ].text }
; } return ( // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
} />
{ /* eslint-disable-next-line react/no-danger */ }
{ excerpt }
); } } const mapDispatchToProps = { selectNote: actions.ui.selectNote, unselectNote: actions.ui.unselectNote, }; export default connect( null, mapDispatchToProps )( SummaryInList );