@infrab4a/connect-angular 4.1.4-beta.3 → 4.1.4-beta.4

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.
@@ -1561,13 +1561,16 @@ class CatalogService {
1561
1561
  };
1562
1562
  }
1563
1563
  async findCatalogIdsByElasticSearch(term) {
1564
- return (this.productsByTerm[term] ||
1565
- this.productIndex.search(term, 999, this.shop).then(({ hits: products }) => {
1566
- const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1567
- const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1568
- const sorted = [...withStock, ...withOutStock];
1569
- return [...new Set(sorted.map(({ _source }) => _source.id))];
1570
- }));
1564
+ if (this.productsByTerm[term])
1565
+ return this.productsByTerm[term];
1566
+ return (this.productsByTerm[term] = await this.productIndex
1567
+ .search(term, 999, this.shop)
1568
+ .then(({ hits: products }) => {
1569
+ const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1570
+ const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1571
+ const sorted = [...withStock, ...withOutStock];
1572
+ return [...new Set(sorted.map(({ _source }) => _source.id))];
1573
+ }));
1571
1574
  }
1572
1575
  }
1573
1576
  CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });