import React, { Component } from 'react' import { Link } from 'react-router-dom' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { formatDateTime } from 'app/utils' import { MenuButton, SmallMenuButton, Loader } from 'app/common' import actions from 'app/actions' import { thumbnailURL } from 'app/views/align/align.util' 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 (

Images

{order.filter(id => lookup[id].type === 'image').map(id => )}

Video

{order.filter(id => lookup[id].type === 'video').map(id => )}
{order.length >= 50 && }
) } } 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)