fix(core): load more entries until viewport is filled (#2415)

This commit is contained in:
Shawn Erquhart 2019-06-28 17:30:39 -04:00 committed by GitHub
parent 0faf2ec8ab
commit a02496b0dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,10 +25,13 @@ export default class EntryListing extends React.Component {
handleCursorActions: PropTypes.func.isRequired, handleCursorActions: PropTypes.func.isRequired,
}; };
hasMore = () => {
return Cursor.create(this.props.cursor).actions.has('append_next');
};
handleLoadMore = () => { handleLoadMore = () => {
const { cursor, handleCursorActions } = this.props; if (this.hasMore()) {
if (Cursor.create(cursor).actions.has('append_next')) { this.props.handleCursorActions('append_next');
handleCursorActions('append_next');
} }
}; };
@ -71,7 +74,7 @@ export default class EntryListing extends React.Component {
{Map.isMap(collections) {Map.isMap(collections)
? this.renderCardsForSingleCollection() ? this.renderCardsForSingleCollection()
: this.renderCardsForMultipleCollections()} : this.renderCardsForMultipleCollections()}
<Waypoint onEnter={this.handleLoadMore} /> {this.hasMore() && <Waypoint onEnter={this.handleLoadMore} />}
</CardsGrid> </CardsGrid>
</div> </div>
); );