@pisell/pisellos 2.2.79 → 2.2.81

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.
@@ -1567,6 +1567,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1567
1567
  if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
1568
1568
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
1569
1569
  if (channelKey === 'product_quotation') {
1570
+ this.clearPriceCache();
1570
1571
  priceRefreshIds.push.apply(priceRefreshIds, _toConsumableArray(msg.relation_product_ids));
1571
1572
  }
1572
1573
  }
@@ -1644,9 +1645,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1644
1645
  sseRefreshCount: uniqueSSEIds.length,
1645
1646
  priceRefreshCount: uniquePriceIds.length
1646
1647
  });
1647
- _context18.next = 72;
1648
+
1649
+ // 如果都没有变更,则不触发 onProductsSyncCompleted
1650
+ if (!(uniqueDeleteIds.length === 0 && bodyUpdates.size === 0 && uniqueSSEIds.length === 0 && uniquePriceIds.length === 0)) {
1651
+ _context18.next = 73;
1652
+ break;
1653
+ }
1654
+ this.logInfo('processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted');
1655
+ return _context18.abrupt("return");
1656
+ case 73:
1657
+ _context18.next = 75;
1648
1658
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
1649
- case 72:
1659
+ case 75:
1650
1660
  case "end":
1651
1661
  return _context18.stop();
1652
1662
  }
@@ -1770,14 +1780,16 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1770
1780
  _context20.next = 10;
1771
1781
  return this.saveProductsToIndexDB(this.store.list);
1772
1782
  case 10:
1773
- this.clearPriceCache();
1783
+ _context20.next = 12;
1784
+ return this.updatePriceCacheForProducts(_toConsumableArray(bodyUpdates.values()));
1785
+ case 12:
1774
1786
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
1775
1787
  this.logInfo('applyBodyUpdatesToStore: 完成', {
1776
1788
  updatedCount: updatedCount,
1777
1789
  newCount: newCount,
1778
1790
  totalCount: this.store.list.length
1779
1791
  });
1780
- case 13:
1792
+ case 14:
1781
1793
  case "end":
1782
1794
  return _context20.stop();
1783
1795
  }
@@ -909,6 +909,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
909
909
  if ((_e = msg.relation_product_ids) == null ? void 0 : _e.length) {
910
910
  sseRefreshIds.push(...msg.relation_product_ids);
911
911
  if (channelKey === "product_quotation") {
912
+ this.clearPriceCache();
912
913
  priceRefreshIds.push(...msg.relation_product_ids);
913
914
  }
914
915
  }
@@ -945,6 +946,10 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
945
946
  sseRefreshCount: uniqueSSEIds.length,
946
947
  priceRefreshCount: uniquePriceIds.length
947
948
  });
949
+ if (uniqueDeleteIds.length === 0 && bodyUpdates.size === 0 && uniqueSSEIds.length === 0 && uniquePriceIds.length === 0) {
950
+ this.logInfo("processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted");
951
+ return;
952
+ }
948
953
  await this.core.effects.emit(import_types.ProductsHooks.onProductsSyncCompleted, null);
949
954
  }
950
955
  /**
@@ -1002,7 +1007,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1002
1007
  }
1003
1008
  this.syncProductsMap();
1004
1009
  await this.saveProductsToIndexDB(this.store.list);
1005
- this.clearPriceCache();
1010
+ await this.updatePriceCacheForProducts([...bodyUpdates.values()]);
1006
1011
  this.core.effects.emit(import_types.ProductsHooks.onProductsChanged, this.store.list);
1007
1012
  this.logInfo("applyBodyUpdatesToStore: 完成", {
1008
1013
  updatedCount,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.79",
4
+ "version": "2.2.81",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",