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

Commit

Permalink
fix(error): reset error when receiving results of a query (not when s…
Browse files Browse the repository at this point in the history
…ending it) (#179)
  • Loading branch information
mthuret authored Jul 21, 2017
1 parent 91c7c5c commit bb12c29
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions packages/react-instantsearch/src/core/createInstantSearchManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import { omit, isEmpty } from 'lodash';
* @param {object} SearchParameters - optional additional parameters to send to the algolia API
* @return {InstantSearchManager} a new instance of InstantSearchManager
*/
export default function createInstantSearchManager({
indexName,
initialState = {},
algoliaClient,
searchParameters = {},
resultsState,
}) {
export default function createInstantSearchManager(
{
indexName,
initialState = {},
algoliaClient,
searchParameters = {},
resultsState,
}
) {
const baseSP = new SearchParameters({
...searchParameters,
index: indexName,
Expand Down Expand Up @@ -84,16 +86,19 @@ export default function createInstantSearchManager({
widget.multiIndexContext &&
widget.multiIndexContext.targetedIndex !== indexName
)
.reduce((indices, widget) => {
const targetedIndex = widget.multiIndexContext.targetedIndex;
const index = indices.find(i => i.targetedIndex === targetedIndex);
if (index) {
index.widgets.push(widget);
} else {
indices.push({ targetedIndex, widgets: [widget] });
}
return indices;
}, []);
.reduce(
(indices, widget) => {
const targetedIndex = widget.multiIndexContext.targetedIndex;
const index = indices.find(i => i.targetedIndex === targetedIndex);
if (index) {
index.widgets.push(widget);
} else {
indices.push({ targetedIndex, widgets: [widget] });
}
return indices;
},
[]
);

const mainIndexParameters = widgetsManager
.getWidgets()
Expand Down Expand Up @@ -164,6 +169,7 @@ export default function createInstantSearchManager({
...store.getState(),
results,
searching: false,
error: null,
},
'resultsFacetValues'
);
Expand All @@ -190,7 +196,6 @@ export default function createInstantSearchManager({
...store.getState(),
metadata,
searching: true,
error: null,
});

// Since the `getSearchParameters` method of widgets also depends on props,
Expand All @@ -217,7 +222,6 @@ export default function createInstantSearchManager({
widgets: nextSearchState,
metadata,
searching: true,
error: null,
});

search();
Expand Down

0 comments on commit bb12c29

Please sign in to comment.