import React, { Component } from 'react' import { Link } from 'react-router-dom' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { formatDateTime } from '../../../util' import { MenuButton, SmallMenuButton, Loader } from '../../../common' import actions from '../../../actions' import MediaIndexOptions from '../components/media.indexOptions' import MediaMenu from '../components/media.menu' // const { result, collectionLookup } = this.props class MediaIndex extends Component { componentDidMount() { this.fetch(false) } componentDidUpdate(prevProps) { if (this.props.media.options.sort !== prevProps.media.options.sort) { this.fetch(false) } } fetch(load_more) { const { options, index } = this.props.media const { order: index_order } = index const [ sort, order ] = options.sort.split('-') actions.media.index({ sort, order, limit: 5000, // offset: load_more ? index_order.length : 0, }, load_more) } render() { const { mediaActions } = this.props const { options } = this.props.media const { loading, lookup, order } = this.props.media.index if (loading) { return (
{order && !!order.length &&
{order.map(id => )}
}
) } if (!lookup || !order.length) { return (

{"No media"}

) } return (
{order.map(id => )}
{order.length >= 50 && }
) } } const thumbnailURL = data => { if (data.type === 'video') return data.settings.video.thumbnail_url } const MediaItem = ({ data }) => { // console.log(data) return (
{data.title}
{data.title}
{data.author}
{data.date}
) } const mapStateToProps = state => ({ media: state.media, }) const mapDispatchToProps = dispatch => ({ // uploadActions: bindActionCreators({ ...uploadActions }, dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(MediaIndex)