react-instantsearch-core
Advanced tools
Comparing version 6.9.0 to 6.10.0
@@ -94,13 +94,10 @@ "use strict"; | ||
this._prevState = this._prevState || {}; | ||
var cache = props.cache || getInMemoryCache(); | ||
this._cache = props.cache ? props.cache : this._cache || getInMemoryCache(); | ||
var cachedHits = this._cache.read({ | ||
state: searchState | ||
}) || {}; | ||
if (this._cachedHits === undefined) { | ||
this._cachedHits = cache.read({ | ||
state: searchState | ||
}) || {}; | ||
} | ||
if (!results) { | ||
return { | ||
hits: extractHitsFromCachedHits(this._cachedHits), | ||
hits: extractHitsFromCachedHits(cachedHits), | ||
hasPrevious: false, | ||
@@ -126,3 +123,3 @@ hasMore: false, | ||
if (!(0, _reactFastCompare.default)(currentState, this._prevState)) { | ||
this._cachedHits = cache.read({ | ||
cachedHits = this._cache.read({ | ||
state: searchState | ||
@@ -132,7 +129,8 @@ }) || {}; | ||
if (this._cachedHits[page] === undefined) { | ||
this._cachedHits[page] = hitsWithPositionsAndQueryID; | ||
cache.write({ | ||
if (cachedHits[page] === undefined) { | ||
cachedHits[page] = hitsWithPositionsAndQueryID; | ||
this._cache.write({ | ||
state: searchState, | ||
hits: this._cachedHits | ||
hits: cachedHits | ||
}); | ||
@@ -144,7 +142,7 @@ } | ||
Math.min() and Math.max() returns Infinity or -Infinity when no argument is given. | ||
But there is always something in this point because of `this._cachedHits[page]`. | ||
But there is always something in this point because of `cachedHits[page]`. | ||
*/ | ||
var firstReceivedPage = Math.min.apply(Math, (0, _toConsumableArray2.default)(Object.keys(this._cachedHits).map(Number))); | ||
var lastReceivedPage = Math.max.apply(Math, (0, _toConsumableArray2.default)(Object.keys(this._cachedHits).map(Number))); | ||
var firstReceivedPage = Math.min.apply(Math, (0, _toConsumableArray2.default)(Object.keys(cachedHits).map(Number))); | ||
var lastReceivedPage = Math.max.apply(Math, (0, _toConsumableArray2.default)(Object.keys(cachedHits).map(Number))); | ||
var hasPrevious = firstReceivedPage > 0; | ||
@@ -163,3 +161,3 @@ var lastPageIndex = nbPages - 1; | ||
return { | ||
hits: extractHitsFromCachedHits(this._cachedHits), | ||
hits: extractHitsFromCachedHits(cachedHits), | ||
hasPrevious: hasPrevious, | ||
@@ -180,3 +178,7 @@ hasMore: hasMore, | ||
refine: function refine(props, searchState, event, index) { | ||
var pages = Object.keys(this._cachedHits || {}).map(Number); | ||
this._cache = props.cache ? props.cache : this._cache || getInMemoryCache(); | ||
var cachedHits = this._cache.read({ | ||
state: searchState | ||
}) || {}; | ||
var pages = Object.keys(cachedHits).map(Number); | ||
var lastReceivedPage = pages.length === 0 ? undefined : Math.max.apply(Math, (0, _toConsumableArray2.default)(pages)); // If there is no key in `this._cachedHits`, | ||
@@ -183,0 +185,0 @@ // then `lastReceivedPage` should be `undefined`. |
@@ -20,2 +20,3 @@ "use strict"; | ||
* @providedPropType {number} nbHits - number of hits returned by Algolia. | ||
* @providedPropType {number} nbSortedHits - number of sorted hits returned by Algolia. | ||
* @providedPropType {number} processingTimeMS - the time in ms took by Algolia to search for results. | ||
@@ -25,3 +26,3 @@ */ | ||
displayName: 'AlgoliaStats', | ||
getProvidedProps: function getProvidedProps(props, searchState, searchResults) { | ||
getProvidedProps: function getProvidedProps(props, _searchState, searchResults) { | ||
var results = (0, _indexUtils.getResults)(searchResults, { | ||
@@ -37,3 +38,5 @@ ais: props.contextValue, | ||
return { | ||
areHitsSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0 && results.nbHits !== results.nbSortedHits, | ||
nbHits: results.nbHits, | ||
nbSortedHits: results.nbSortedHits, | ||
processingTimeMS: results.processingTimeMS | ||
@@ -40,0 +43,0 @@ }; |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var _default = '6.9.0'; | ||
var _default = '6.10.0'; | ||
exports.default = _default; |
@@ -41,2 +41,3 @@ "use strict"; | ||
connectSearchBox: true, | ||
connectSmartSort: true, | ||
connectSortBy: true, | ||
@@ -241,2 +242,8 @@ connectStateResults: true, | ||
}); | ||
Object.defineProperty(exports, "connectSmartSort", { | ||
enumerable: true, | ||
get: function get() { | ||
return _connectSmartSort.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "connectSortBy", { | ||
@@ -339,2 +346,4 @@ enumerable: true, | ||
var _connectSmartSort = _interopRequireDefault(require("./connectors/connectSmartSort")); | ||
var _connectSortBy = _interopRequireDefault(require("./connectors/connectSortBy")); | ||
@@ -341,0 +350,0 @@ |
@@ -79,13 +79,10 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
this._prevState = this._prevState || {}; | ||
var cache = props.cache || getInMemoryCache(); | ||
this._cache = props.cache ? props.cache : this._cache || getInMemoryCache(); | ||
var cachedHits = this._cache.read({ | ||
state: searchState | ||
}) || {}; | ||
if (this._cachedHits === undefined) { | ||
this._cachedHits = cache.read({ | ||
state: searchState | ||
}) || {}; | ||
} | ||
if (!results) { | ||
return { | ||
hits: extractHitsFromCachedHits(this._cachedHits), | ||
hits: extractHitsFromCachedHits(cachedHits), | ||
hasPrevious: false, | ||
@@ -113,3 +110,3 @@ hasMore: false, | ||
if (!isEqual(currentState, this._prevState)) { | ||
this._cachedHits = cache.read({ | ||
cachedHits = this._cache.read({ | ||
state: searchState | ||
@@ -119,7 +116,8 @@ }) || {}; | ||
if (this._cachedHits[page] === undefined) { | ||
this._cachedHits[page] = hitsWithPositionsAndQueryID; | ||
cache.write({ | ||
if (cachedHits[page] === undefined) { | ||
cachedHits[page] = hitsWithPositionsAndQueryID; | ||
this._cache.write({ | ||
state: searchState, | ||
hits: this._cachedHits | ||
hits: cachedHits | ||
}); | ||
@@ -131,7 +129,7 @@ } | ||
Math.min() and Math.max() returns Infinity or -Infinity when no argument is given. | ||
But there is always something in this point because of `this._cachedHits[page]`. | ||
But there is always something in this point because of `cachedHits[page]`. | ||
*/ | ||
var firstReceivedPage = Math.min.apply(Math, _toConsumableArray(Object.keys(this._cachedHits).map(Number))); | ||
var lastReceivedPage = Math.max.apply(Math, _toConsumableArray(Object.keys(this._cachedHits).map(Number))); | ||
var firstReceivedPage = Math.min.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number))); | ||
var lastReceivedPage = Math.max.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number))); | ||
var hasPrevious = firstReceivedPage > 0; | ||
@@ -150,3 +148,3 @@ var lastPageIndex = nbPages - 1; | ||
return { | ||
hits: extractHitsFromCachedHits(this._cachedHits), | ||
hits: extractHitsFromCachedHits(cachedHits), | ||
hasPrevious: hasPrevious, | ||
@@ -167,3 +165,7 @@ hasMore: hasMore, | ||
refine: function refine(props, searchState, event, index) { | ||
var pages = Object.keys(this._cachedHits || {}).map(Number); | ||
this._cache = props.cache ? props.cache : this._cache || getInMemoryCache(); | ||
var cachedHits = this._cache.read({ | ||
state: searchState | ||
}) || {}; | ||
var pages = Object.keys(cachedHits).map(Number); | ||
var lastReceivedPage = pages.length === 0 ? undefined : Math.max.apply(Math, _toConsumableArray(pages)); // If there is no key in `this._cachedHits`, | ||
@@ -170,0 +172,0 @@ // then `lastReceivedPage` should be `undefined`. |
@@ -9,2 +9,3 @@ import createConnector from '../core/createConnector'; | ||
* @providedPropType {number} nbHits - number of hits returned by Algolia. | ||
* @providedPropType {number} nbSortedHits - number of sorted hits returned by Algolia. | ||
* @providedPropType {number} processingTimeMS - the time in ms took by Algolia to search for results. | ||
@@ -15,3 +16,3 @@ */ | ||
displayName: 'AlgoliaStats', | ||
getProvidedProps: function getProvidedProps(props, searchState, searchResults) { | ||
getProvidedProps: function getProvidedProps(props, _searchState, searchResults) { | ||
var results = getResults(searchResults, { | ||
@@ -27,3 +28,5 @@ ais: props.contextValue, | ||
return { | ||
areHitsSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0 && results.nbHits !== results.nbSortedHits, | ||
nbHits: results.nbHits, | ||
nbSortedHits: results.nbSortedHits, | ||
processingTimeMS: results.processingTimeMS | ||
@@ -30,0 +33,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
export default '6.9.0'; | ||
export default '6.10.0'; |
@@ -35,2 +35,3 @@ // Core | ||
export { default as connectSearchBox } from './connectors/connectSearchBox'; | ||
export { default as connectSmartSort } from './connectors/connectSmartSort'; | ||
export { default as connectSortBy } from './connectors/connectSortBy'; | ||
@@ -37,0 +38,0 @@ export { default as connectStateResults } from './connectors/connectStateResults'; |
{ | ||
"name": "react-instantsearch-core", | ||
"version": "6.9.0", | ||
"version": "6.10.0", | ||
"description": "⚡ Lightning-fast search for React, by Algolia", | ||
@@ -42,3 +42,3 @@ "main": "dist/cjs/index.js", | ||
"@babel/runtime": "^7.1.2", | ||
"algoliasearch-helper": "^3.1.0", | ||
"algoliasearch-helper": "^3.4.3", | ||
"prop-types": "^15.6.2", | ||
@@ -45,0 +45,0 @@ "react-fast-compare": "^3.0.0" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2096017
98
20187
Updatedalgoliasearch-helper@^3.4.3