@shopgate/engage 7.30.2-beta.3 → 7.30.3-beta.1

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.
@@ -1,3 +1,4 @@
1
+ import chunk from 'lodash/chunk';
1
2
  import { getProductsResult, productIsReady$, productsReceived$, productsReceivedCached$, RECEIVE_PRODUCTS_CACHED, variantDidChange$ } from '@shopgate/engage/product';
2
3
  import { appDidStart$, routeWillEnter$, UIEvents, getCurrentRoute, hex2bin, getThemeSettings, getCurrentSearchQuery, appWillInit$, appInitialization } from '@shopgate/engage/core';
3
4
  import { cartReceived$, fetchCart, cartDidEnter$, getCartItems } from '@shopgate/engage/cart';
@@ -52,6 +53,7 @@ const setLocationOnceAvailable = async (locationCode, dispatch) => {
52
53
  // Location won't be set.
53
54
  }
54
55
  };
56
+ const MAX_PRODUCT_CODES_PER_INVENTORY_REQUEST = 100;
55
57
 
56
58
  /**
57
59
  * Locations subscriptions.
@@ -316,7 +318,12 @@ function locationsSubscriber(subscribe) {
316
318
  const productCodes = products.map(({
317
319
  id
318
320
  }) => id);
319
- dispatch(fetchInventories(productCodes));
321
+
322
+ // fetchInventories requests for too many product codes can cause request errors, so we
323
+ // split them into chunked requests if necessary.
324
+ chunk(productCodes, MAX_PRODUCT_CODES_PER_INVENTORY_REQUEST).forEach(productCodesChunk => {
325
+ dispatch(fetchInventories(productCodesChunk));
326
+ });
320
327
  });
321
328
  subscribe(productsReceived$.merge(productsReceivedCached$), ({
322
329
  action,
@@ -332,7 +339,12 @@ function locationsSubscriber(subscribe) {
332
339
  const productCodes = action.type !== RECEIVE_PRODUCTS_CACHED ? action.products.map(({
333
340
  id
334
341
  }) => id) : action.products;
335
- dispatch(fetchInventories(productCodes));
342
+
343
+ // fetchInventories requests for too many product codes can cause request errors, so we
344
+ // split them into chunked requests if necessary.
345
+ chunk(productCodes, MAX_PRODUCT_CODES_PER_INVENTORY_REQUEST).forEach(productCodesChunk => {
346
+ dispatch(fetchInventories(productCodesChunk));
347
+ });
336
348
  });
337
349
  subscribe(receiveFavoritesWhileVisible$.merge(preferredLocationDidUpdateGlobalOnWishlist$), ({
338
350
  dispatch,
@@ -346,7 +358,12 @@ function locationsSubscriber(subscribe) {
346
358
  if (!productIds || !productIds.length) {
347
359
  return;
348
360
  }
349
- dispatch(fetchInventories(productIds));
361
+
362
+ // fetchInventories requests for too many product codes can cause request errors, so we
363
+ // split them into chunked requests if necessary.
364
+ chunk(productIds, MAX_PRODUCT_CODES_PER_INVENTORY_REQUEST).forEach(productIdsChunk => {
365
+ dispatch(fetchInventories(productIdsChunk));
366
+ });
350
367
  });
351
368
  subscribe(appDidStart$, ({
352
369
  getState
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "7.30.2-beta.3",
3
+ "version": "7.30.3-beta.1",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -17,12 +17,12 @@
17
17
  "dependencies": {
18
18
  "@emotion/react": "^11.14.0",
19
19
  "@shopgate/native-modules": "1.0.0-beta.25",
20
- "@shopgate/pwa-common": "7.30.2-beta.3",
21
- "@shopgate/pwa-common-commerce": "7.30.2-beta.3",
22
- "@shopgate/pwa-core": "7.30.2-beta.3",
23
- "@shopgate/pwa-ui-ios": "7.30.2-beta.3",
24
- "@shopgate/pwa-ui-material": "7.30.2-beta.3",
25
- "@shopgate/pwa-ui-shared": "7.30.2-beta.3",
20
+ "@shopgate/pwa-common": "7.30.3-beta.1",
21
+ "@shopgate/pwa-common-commerce": "7.30.3-beta.1",
22
+ "@shopgate/pwa-core": "7.30.3-beta.1",
23
+ "@shopgate/pwa-ui-ios": "7.30.3-beta.1",
24
+ "@shopgate/pwa-ui-material": "7.30.3-beta.1",
25
+ "@shopgate/pwa-ui-shared": "7.30.3-beta.1",
26
26
  "@stripe/react-stripe-js": "^1.16.5",
27
27
  "@stripe/stripe-js": "^1.44.1",
28
28
  "@virtuous/conductor": "~2.5.0",