import React from 'react' import { Link } from 'react-router-dom' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { Keyframe } from '.' import * as reviewActions from '../review/review.actions' import * as searchActions from '../search/search.actions' function Keyframes(props) { // console.log(props) let { frames, groupByHash, } = props let minDistance = 0 if (frames && frames.length) { minDistance = frames[0].distance || 0 } if (!groupByHash) { return ( ) } const frameGroups = frames.reduce((a, b) => { if (a[b.hash]) { a[b.hash].push(b) } else { a[b.hash] = [b] } return a }, {}) return Object.keys(frameGroups) .map(hash => [frameGroups[hash].length, hash]) .sort((a, b) => b[0] - a[0]) .map(([count, hash]) => ( )) } function KeyframeList(props) { let { saved = {}, frames, options, review, search, minDistance, label, count, ...frameProps } = props if (!frames) return null return (
{label &&

{label} ({count})

} {frames.map(({ hash, frame, verified, distance }) => ( review.toggleSaved({ verified, hash, frame })} reviewActions={review} {...frameProps} /> ))}
) } const mapStateToProps = state => ({ saved: state.review.saved, options: state.search.options, }) const mapDispatchToProps = dispatch => ({ review: bindActionCreators({ ...reviewActions }, dispatch), search: bindActionCreators({ ...searchActions }, dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(Keyframes)