Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(connectInfiniteHits): always provide an array for hits (#1064)
Browse files Browse the repository at this point in the history
* refactor(connectInfiniteHits): isolate test from each others

* fix(connectInfiniteHits): always provide an array for hits
  • Loading branch information
samouss authored Mar 12, 2018
1 parent 0ffd9a4 commit c75e38b
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ export default createConnector({
getProvidedProps(props, searchState, searchResults) {
const results = getResults(searchResults, this.context);

this._allResults = this._allResults || [];

if (!results) {
this._allResults = [];
return {
hits: this._allResults,
hits: [],
hasMore: false,
};
}

const { hits, page, nbPages } = results;

// If it is the same page we do not touch the page result list
if (page === 0) {
this._allResults = hits;
} else if (page > this.previousPage) {
Expand All @@ -64,7 +64,9 @@ export default createConnector({

const lastPageIndex = nbPages - 1;
const hasMore = page < lastPageIndex;

this.previousPage = page;

return {
hits: this._allResults,
hasMore,
Expand Down
Loading

0 comments on commit c75e38b

Please sign in to comment.