@@ -10,19 +10,23 @@ import AutoSizer from 'react-virtualized/dist/es/AutoSizer';
1010import { CellMeasurer , CellMeasurerCache } from 'react-virtualized/dist/es/CellMeasurer' ;
1111import 'react-virtualized/styles.css' ;
1212import { formatTime } from '../../util/datetime' ;
13- import type { SkillData } from '../../flowTypes' ;
13+ import type { SkillData , TimeSlice , SkillDataEntry } from '../../flowTypes' ;
1414import './Transcript.scss' ;
1515
1616type Props = {
17- skill : SkillData
17+ skill : SkillData ,
18+ getPreviewer ?: Function
1819} ;
1920
2021const cache = new CellMeasurerCache ( {
2122 minHeight : 20 ,
2223 fixedWidth : true
2324} ) ;
2425
25- const Transcript = ( { skill : { entries } } : Props ) =>
26+ const isValidStartTime = ( cellData ?: TimeSlice [ ] ) : boolean =>
27+ Array . isArray ( cellData ) && ! ! cellData [ 0 ] && typeof cellData [ 0 ] . start === 'number' ;
28+
29+ const Transcript = ( { skill : { entries } , getPreviewer } : Props ) =>
2630 < AutoSizer disableHeight >
2731 { ( { width } ) =>
2832 < Table
@@ -35,18 +39,29 @@ const Transcript = ({ skill: { entries } }: Props) =>
3539 rowGetter = { ( { index } ) => entries [ index ] }
3640 className = 'buik-transcript'
3741 deferredMeasurementCache = { cache }
42+ onRowClick = { ( { rowData } : { rowData : SkillDataEntry } ) : void => {
43+ const viewer = getPreviewer ? getPreviewer ( ) : null ;
44+ const cellData = rowData . appears ;
45+ if (
46+ isValidStartTime ( cellData ) &&
47+ viewer &&
48+ viewer . isLoaded ( ) &&
49+ ! viewer . isDestroyed ( ) &&
50+ typeof viewer . play === 'function'
51+ ) {
52+ // $FlowFixMe Already checked above
53+ const { start, end } = cellData [ 0 ] ;
54+ viewer . play ( start , end ) ;
55+ }
56+ } }
3857 >
3958 < Column
4059 dataKey = 'appears'
4160 className = 'buik-transcript-time-column'
4261 width = { 45 }
4362 flexShrink = { 0 }
44- cellRenderer = { ( { cellData } ) : string => {
45- if ( Array . isArray ( cellData ) && ! ! cellData [ 0 ] && typeof cellData [ 0 ] . start === 'number' ) {
46- return formatTime ( cellData [ 0 ] . start ) ;
47- }
48- return '--' ;
49- } }
63+ cellRenderer = { ( { cellData } ) : string =>
64+ isValidStartTime ( cellData ) ? formatTime ( cellData [ 0 ] . start ) : '--' }
5065 />
5166 < Column
5267 dataKey = 'text'
0 commit comments