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

fix(connectRange): check if facet exist before access #797

Merged
merged 3 commits into from
Jan 8, 2018

Conversation

samouss
Copy link
Collaborator

@samouss samouss commented Jan 4, 2018

Summary

Fix #630

In the connectRange we need to access the stats & the values of the given facet in order to compute the range. But it may happen that the facet is not yet present on the results so we need to check that the facet is present on results before accessing it.

@samouss samouss force-pushed the fix/connect-range-facet-access branch from ccc3a2d to 9952766 Compare January 4, 2018 17:32
@algolia algolia deleted a comment from algobot Jan 4, 2018
@algobot
Copy link
Contributor

algobot commented Jan 4, 2018

Deploy preview ready!

Built with commit 04f2e07

https://deploy-preview-797--react-instantsearch.netlify.com

@samouss samouss force-pushed the fix/connect-range-facet-access branch 4 times, most recently from 169e330 to 83f98d8 Compare January 5, 2018 12:10
@samouss samouss requested a review from vvo January 5, 2018 17:01
@samouss samouss force-pushed the fix/connect-range-facet-access branch 2 times, most recently from b7acfcc to 6505f85 Compare January 8, 2018 09:18
@samouss samouss force-pushed the fix/connect-range-facet-access branch from 6505f85 to 735b21b Compare January 8, 2018 14:17
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just a proposed name change

@@ -190,8 +190,13 @@ export default createConnector({
getProvidedProps(props, searchState, searchResults) {
const { attributeName, precision, min: minBound, max: maxBound } = props;
const results = getResults(searchResults, this.context);
const stats = results ? results.getFacetStats(attributeName) || {} : {};
const count = results
const isFacetExist = results && results.getFacetByName(attributeName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

facetExists seems like a better name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to prefix all the boolean value like one with is or has it make them explicit. Would you agree for isFacetExists ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, but grammatically it reads weird. What about hasFacet as something which matches the pattern but also grammar?

@samouss
Copy link
Collaborator Author

samouss commented Jan 8, 2018

@Haroenv should be good now!

@samouss samouss merged commit 6520760 into master Jan 8, 2018
@samouss samouss deleted the fix/connect-range-facet-access branch January 8, 2018 20:01
samouss added a commit that referenced this pull request Jan 9, 2018
<a name="4.4.1"></a>
## [4.4.1](v4.4.0...v4.4.1) (2018-01-09)

### Bug Fixes

* **SearchBox**: clear SearchBox without search as you type ([#802](#802)) ([c49b2b6](c49b2b6))
* **connectRange:** check if facet exist before access ([#797](#797)) ([6520760](6520760))
* **stories:** avoid to use linear-background it breaks Argos every time ([#804](#804)) ([0beded7](0beded7))
* **stories:** limit hits per page on Index ([#806](#806)) ([6eb14d3](6eb14d3))

### Features

* **Index:** allow custom root ([#792](#792)) ([d793b0a](d793b0a))
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants