import React from 'react'; import {closeActionsMenu} from '../helpers'; import {gettext} from 'core/utils'; import ng from 'core/services/ng'; import {IArticle} from 'superdesk-api'; interface IProps { item: IArticle; highlights: any; highlightsById: any; } export class HighlightsList extends React.Component { static propTypes: any; static defaultProps: any; timeout: any; highlightsService: any; $rootScope: any; $timeout: any; constructor(props) { super(props); this.removeHighlight = this.removeHighlight.bind(this); this.stopTimeout = this.stopTimeout.bind(this); this.close = this.close.bind(this); this.closeMenu = this.closeMenu.bind(this); this.highlightsService = ng.get('highlightsService'); this.$rootScope = ng.get('$rootScope'); this.$timeout = ng.get('$timeout'); } removeHighlight(highlight, event) { event.stopPropagation(); this.highlightsService.markItem(highlight._id, this.props.item); this.closeMenu(); } componentDidMount() { this.timeout = null; } componentWillUnmount() { this.stopTimeout(); } stopTimeout() { this.timeout = this.$timeout.cancel(this.timeout); } closeMenu() { closeActionsMenu(this.props.item._id); } close() { this.timeout = this.$timeout(this.closeMenu, 2000, false); } render() { const highlights = this.props.highlights; const highlightsById = this.props.highlightsById || {}; return ( ); } }