From ff87469f062d299b4a16aae5d790028d3380123d Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Tue, 19 Dec 2017 11:40:24 -0500 Subject: [PATCH] fix infinite scrolling for collections with integrations --- .../Collection/Entries/EntriesCollection.js | 26 ++++++++++++------- .../Collection/Entries/EntriesSearch.js | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/components/Collection/Entries/EntriesCollection.js b/src/components/Collection/Entries/EntriesCollection.js index 37b727471795..cf0c410bd027 100644 --- a/src/components/Collection/Entries/EntriesCollection.js +++ b/src/components/Collection/Entries/EntriesCollection.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; -import { loadEntries } from 'Actions/entries'; +import { loadEntries as actionLoadEntries } from 'Actions/entries'; import { selectEntries } from 'Reducers'; import Entries from './Entries'; @@ -10,7 +10,6 @@ class EntriesCollection extends React.Component { static propTypes = { collection: ImmutablePropTypes.map.isRequired, publicFolder: PropTypes.string.isRequired, - dispatch: PropTypes.func.isRequired, page: PropTypes.number, entries: ImmutablePropTypes.list, isFetching: PropTypes.bool.isRequired, @@ -18,21 +17,26 @@ class EntriesCollection extends React.Component { }; componentDidMount() { - const { collection, dispatch } = this.props; + const { collection, loadEntries } = this.props; if (collection) { - dispatch(loadEntries(collection)); + loadEntries(collection); } } componentWillReceiveProps(nextProps) { - const { collection, dispatch } = this.props; + const { collection, loadEntries } = this.props; if (nextProps.collection !== collection) { - dispatch(loadEntries(nextProps.collection)); + loadEntries(nextProps.collection); } } + handleLoadMore = page => { + const { collection, loadEntries } = this.props; + loadEntries(collection, page); + } + render () { - const { dispatch, collection, entries, publicFolder, page, isFetching, viewStyle } = this.props; + const { collection, entries, publicFolder, page, isFetching, viewStyle } = this.props; return ( dispatch(loadEntries(collection, page))} + onPaginate={this.handleLoadMore} isFetching={isFetching} collectionName={collection.get('label')} viewStyle={viewStyle} @@ -61,4 +65,8 @@ function mapStateToProps(state, ownProps) { return { publicFolder, collection, page, entries, isFetching, viewStyle }; } -export default connect(mapStateToProps)(EntriesCollection); +const mapDispatchToProps = { + loadEntries: actionLoadEntries, +}; + +export default connect(mapStateToProps, mapDispatchToProps)(EntriesCollection); diff --git a/src/components/Collection/Entries/EntriesSearch.js b/src/components/Collection/Entries/EntriesSearch.js index 02c66ffa3b3a..daf58d006255 100644 --- a/src/components/Collection/Entries/EntriesSearch.js +++ b/src/components/Collection/Entries/EntriesSearch.js @@ -42,7 +42,7 @@ class EntriesSearch extends React.Component { }; render () { - const { dispatch, collections, entries, publicFolder, page, isFetching } = this.props; + const { collections, entries, publicFolder, page, isFetching } = this.props; return (