import React, { Component } from 'react' // import { Link } from 'react-router-dom' // import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import actions from 'app/actions' import { timestampToSeconds } from 'app/utils' import ParagraphList from 'app/views/paragraph/components/paragraph.list' import { inlineComponents } from './components.inline' class PlayerTranscript extends Component { constructor(props){ super(props) this.handleAnnotationClick = this.handleAnnotationClick.bind(this) this.handleParagraphDoubleClick = this.handleParagraphDoubleClick.bind(this) this.handleScroll = this.handleScroll.bind(this) this.containerRef = React.createRef() } componentDidUpdate(prevProps) { if (this.props.section !== prevProps.section) { this.containerRef.current.scrollTo(0, 0) setTimeout(() => { this.containerRef.current.scrollTo(0, 0) }, 20) } } handleAnnotationClick(e, paragraph, annotation) { // console.log(annotation) if (annotation.type === 'footnote') { return actions.viewer.openFootnote(annotation) } if (annotation.settings.override_start_ts) { const ts = timestampToSeconds(annotation.settings.override_start_ts) if (ts) { actions.audio.seek(ts) } } else { actions.audio.seek(paragraph.start_ts) } actions.audio.play() } handleParagraphDoubleClick(e, paragraph) { } handleScroll(e) { if (this.props.viewer.growlOpen) { actions.viewer.closeGrowl() if (this.props.viewer.currentSection.index === 0) { actions.audio.play() } } } render() { const { paragraphs, color, inlineParagraphCount } = this.props.section const className = "player-transcript " + color + " " + ( inlineParagraphCount > 2 ? 'scrollable' : 'not-scrollable' ) return (