instantsearch.js 4.79.1 → 4.79.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,22 +98,20 @@ var connectInfiniteHits = exports.default = function connectInfiniteHits(renderF
98
98
  return Math.max.apply(Math, [page].concat(_toConsumableArray(pages)));
99
99
  }
100
100
  };
101
- var getShowPrevious = function getShowPrevious(helper) {
101
+ var getShowPrevious = function getShowPrevious(helper, getCachedHits) {
102
102
  return function () {
103
+ var cachedHits = getCachedHits();
103
104
  // Using the helper's `overrideStateWithoutTriggeringChangeEvent` method
104
105
  // avoid updating the browser URL when the user displays the previous page.
105
106
  helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread(_objectSpread({}, helper.state), {}, {
106
- page: getFirstReceivedPage(helper.state, cache.read({
107
- state: normalizeState(helper.state)
108
- }) || {}) - 1
107
+ page: getFirstReceivedPage(helper.state, cachedHits) - 1
109
108
  })).searchWithoutTriggeringOnStateChange();
110
109
  };
111
110
  };
112
- var getShowMore = function getShowMore(helper) {
111
+ var getShowMore = function getShowMore(helper, getCachedHits) {
113
112
  return function () {
114
- helper.setPage(getLastReceivedPage(helper.state, cache.read({
115
- state: normalizeState(helper.state)
116
- }) || {}) + 1).search();
113
+ var cachedHits = getCachedHits();
114
+ helper.setPage(getLastReceivedPage(helper.state, cachedHits) + 1).search();
117
115
  };
118
116
  };
119
117
  return {
@@ -145,6 +143,12 @@ var connectInfiniteHits = exports.default = function connectInfiniteHits(renderF
145
143
  parent = _ref6.parent,
146
144
  existingState = _ref6.state,
147
145
  instantSearchInstance = _ref6.instantSearchInstance;
146
+ var getCacheHits = function getCacheHits() {
147
+ var state = parent.getPreviousState() || existingState;
148
+ return cache.read({
149
+ state: normalizeState(state)
150
+ }) || {};
151
+ };
148
152
  var isFirstPage;
149
153
  var currentPageHits = [];
150
154
  /**
@@ -153,13 +157,15 @@ var connectInfiniteHits = exports.default = function connectInfiniteHits(renderF
153
157
  * is loading.
154
158
  */
155
159
  var state = parent.getPreviousState() || existingState;
156
- var cachedHits = cache.read({
157
- state: normalizeState(state)
158
- }) || {};
160
+ var cachedHits = getCacheHits();
159
161
  var banner = results === null || results === void 0 ? void 0 : (_results$renderingCon = results.renderingContent) === null || _results$renderingCon === void 0 ? void 0 : (_results$renderingCon2 = _results$renderingCon.widgets) === null || _results$renderingCon2 === void 0 ? void 0 : (_results$renderingCon3 = _results$renderingCon2.banners) === null || _results$renderingCon3 === void 0 ? void 0 : _results$renderingCon3[0];
160
162
  if (!showPrevious) {
161
- showPrevious = getShowPrevious(helper);
162
- showMore = getShowMore(helper);
163
+ showPrevious = function showPrevious() {
164
+ return getShowPrevious(helper, getCacheHits)();
165
+ };
166
+ showMore = function showMore() {
167
+ return getShowMore(helper, getCacheHits)();
168
+ };
163
169
  }
164
170
  if (!sendEvent) {
165
171
  sendEvent = (0, _utils.createSendEventForHits)({
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '4.79.1';
7
+ var _default = exports.default = '4.79.2';
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.79.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! InstantSearch.js 4.79.2 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -10235,22 +10235,20 @@
10235
10235
  return Math.max.apply(Math, [page].concat(_toConsumableArray(pages)));
10236
10236
  }
10237
10237
  };
10238
- var getShowPrevious = function getShowPrevious(helper) {
10238
+ var getShowPrevious = function getShowPrevious(helper, getCachedHits) {
10239
10239
  return function () {
10240
+ var cachedHits = getCachedHits();
10240
10241
  // Using the helper's `overrideStateWithoutTriggeringChangeEvent` method
10241
10242
  // avoid updating the browser URL when the user displays the previous page.
10242
10243
  helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), {}, {
10243
- page: getFirstReceivedPage(helper.state, cache.read({
10244
- state: normalizeState(helper.state)
10245
- }) || {}) - 1
10244
+ page: getFirstReceivedPage(helper.state, cachedHits) - 1
10246
10245
  })).searchWithoutTriggeringOnStateChange();
10247
10246
  };
10248
10247
  };
10249
- var getShowMore = function getShowMore(helper) {
10248
+ var getShowMore = function getShowMore(helper, getCachedHits) {
10250
10249
  return function () {
10251
- helper.setPage(getLastReceivedPage(helper.state, cache.read({
10252
- state: normalizeState(helper.state)
10253
- }) || {}) + 1).search();
10250
+ var cachedHits = getCachedHits();
10251
+ helper.setPage(getLastReceivedPage(helper.state, cachedHits) + 1).search();
10254
10252
  };
10255
10253
  };
10256
10254
  return {
@@ -10282,6 +10280,12 @@
10282
10280
  parent = _ref6.parent,
10283
10281
  existingState = _ref6.state,
10284
10282
  instantSearchInstance = _ref6.instantSearchInstance;
10283
+ var getCacheHits = function getCacheHits() {
10284
+ var state = parent.getPreviousState() || existingState;
10285
+ return cache.read({
10286
+ state: normalizeState(state)
10287
+ }) || {};
10288
+ };
10285
10289
  var isFirstPage;
10286
10290
  var currentPageHits = [];
10287
10291
  /**
@@ -10290,13 +10294,15 @@
10290
10294
  * is loading.
10291
10295
  */
10292
10296
  var state = parent.getPreviousState() || existingState;
10293
- var cachedHits = cache.read({
10294
- state: normalizeState(state)
10295
- }) || {};
10297
+ var cachedHits = getCacheHits();
10296
10298
  var banner = results === null || results === void 0 ? void 0 : (_results$renderingCon = results.renderingContent) === null || _results$renderingCon === void 0 ? void 0 : (_results$renderingCon2 = _results$renderingCon.widgets) === null || _results$renderingCon2 === void 0 ? void 0 : (_results$renderingCon3 = _results$renderingCon2.banners) === null || _results$renderingCon3 === void 0 ? void 0 : _results$renderingCon3[0];
10297
10299
  if (!showPrevious) {
10298
- showPrevious = getShowPrevious(helper);
10299
- showMore = getShowMore(helper);
10300
+ showPrevious = function showPrevious() {
10301
+ return getShowPrevious(helper, getCacheHits)();
10302
+ };
10303
+ showMore = function showMore() {
10304
+ return getShowMore(helper, getCacheHits)();
10305
+ };
10300
10306
  }
10301
10307
  if (!sendEvent) {
10302
10308
  sendEvent = createSendEventForHits({
@@ -16434,7 +16440,7 @@
16434
16440
  };
16435
16441
  }
16436
16442
 
16437
- var version$1 = '4.79.1';
16443
+ var version$1 = '4.79.2';
16438
16444
 
16439
16445
  var withUsage$v = createDocumentationMessageGenerator({
16440
16446
  name: 'instantsearch'