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