ng-miam 6.3.11 → 6.3.12

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.
@@ -779,13 +779,14 @@
779
779
  // Unused in sdk at the moment but any client app can subscribe on it to know when a recipe has been added
780
780
  _this.recipeWasDeleted$ = new rxjs.BehaviorSubject([]);
781
781
  _this.recipesToRemove = new rxjs.BehaviorSubject([]);
782
+ _this.isRemovingRecipes = false;
782
783
  // Singleton instance of GroceriesList
783
784
  _this._list$ = new rxjs.BehaviorSubject(null);
784
785
  _this.saveOperationType = '';
785
786
  // Observe the fetching of the recipe so calls to list$ are delayed instead of calling refreshCurrentList dozens of times
786
787
  _this.listIsFetching = false;
787
788
  _this.register();
788
- _this.recipesToRemove.pipe(operators.skipWhile(function (toRemove) { return toRemove.length === 0; }), operators.debounceTime(1000), operators.switchMap(function () { return _this.emptyRecipesToRemove(); })).subscribe();
789
+ _this.recipesToRemove.pipe(operators.skipWhile(function (toRemove) { return toRemove.length === 0 || _this.isRemovingRecipes; }), operators.debounceTime(200), operators.tap(function () { return _this.emptyRecipesToRemove(); })).subscribe();
789
790
  return _this;
790
791
  }
791
792
  Object.defineProperty(GroceriesListsService.prototype, "list$", {
@@ -939,22 +940,24 @@
939
940
  };
940
941
  GroceriesListsService.prototype.emptyRecipesToRemove = function () {
941
942
  var _this = this;
943
+ this.isRemovingRecipes = true;
942
944
  var idsToRemove = this.recipesToRemove.value.map(function (i) { return i.id; });
943
945
  if (idsToRemove.length > 0) {
944
946
  var eventTrace_1 = this.recipesToRemove.value[0].eventTrace;
945
- return this.takeFirstList().pipe(operators.switchMap(function (list) {
947
+ this.takeFirstList().pipe(operators.switchMap(function (list) {
946
948
  if (list.attributes['recipes-infos']) {
947
949
  list.attributes['recipes-infos'] = list.attributes['recipes-infos'].filter(function (info) {
948
950
  return !idsToRemove.includes(info.id);
949
951
  });
950
952
  _this.analyticsService.sendEventWhenReady(_this.analyticsService.EVENT_RECIPE_REMOVE, eventTrace_1.originPath, eventTrace_1.props);
951
953
  _this.saveOperationType = 'REMOVE';
952
- return _this.saveList(list).pipe(operators.take(1), operators.tap(function () { return _this.recipesToRemove.next(_this.recipesToRemove.value.filter(function (i) { return !idsToRemove.includes(i.id); })); }));
954
+ return _this.saveList(list).pipe(operators.take(1));
953
955
  }
954
- return rxjs.of(null);
955
- }));
956
+ })).subscribe(function () {
957
+ _this.isRemovingRecipes = false;
958
+ _this.recipesToRemove.next(_this.recipesToRemove.value.filter(function (i) { return !idsToRemove.includes(i.id); }));
959
+ });
956
960
  }
957
- return rxjs.of(null);
958
961
  };
959
962
  /**
960
963
  * save() returns an object that isn't a resource so methods aren't attached, so we have to do a little trick
@@ -972,16 +975,19 @@
972
975
  delete (list.attributes['recipes-ids']);
973
976
  delete (list.relationships['groceries-entries']);
974
977
  return list.save({ include: ['groceries-entries'] }).pipe(operators.skipWhile(function (l) { return l.is_loading; }), operators.tap(function (l) {
975
- _this._list$.next(_this.afterSave(l));
976
- if (_this.saveOperationType === 'ADD') {
977
- _this.recipeWasAdded$.next(list.recipeInfos);
978
- }
979
- if (_this.saveOperationType === 'REMOVE') {
980
- _this.recipeWasDeleted$.next(list.recipeInfos);
981
- }
982
- _this.saveOperationType = '';
983
- if (openBasket) {
984
- window.open(_this.miamBasketURL + "/" + list.id, '_blank');
978
+ var _a;
979
+ if ((_a = l === null || l === void 0 ? void 0 : l.data) === null || _a === void 0 ? void 0 : _a.id) {
980
+ _this._list$.next(_this.afterSave(l));
981
+ if (_this.saveOperationType === 'ADD') {
982
+ _this.recipeWasAdded$.next(list.recipeInfos);
983
+ }
984
+ if (_this.saveOperationType === 'REMOVE') {
985
+ _this.recipeWasDeleted$.next(list.recipeInfos);
986
+ }
987
+ _this.saveOperationType = '';
988
+ if (openBasket) {
989
+ window.open(_this.miamBasketURL + "/" + list.id, '_blank');
990
+ }
985
991
  }
986
992
  }), operators.map(function (l) { return l.data; }));
987
993
  };
@@ -13124,9 +13130,16 @@
13124
13130
  }
13125
13131
  };
13126
13132
  BasketPreviewDisabledComponent.prototype.ngOnChanges = function () {
13133
+ var _this = this;
13127
13134
  if (this.alwaysExpanded) {
13128
13135
  this.reduced = false;
13129
13136
  }
13137
+ Object.keys(this.loading).forEach(function (id) {
13138
+ var _a;
13139
+ if (((_a = _this.entries) === null || _a === void 0 ? void 0 : _a.filter(function (entry) { return entry.id === id; }).length) === 0) {
13140
+ delete _this.loading[id];
13141
+ }
13142
+ });
13130
13143
  };
13131
13144
  BasketPreviewDisabledComponent.prototype.onResize = function (event) {
13132
13145
  this.mobile = window.innerWidth <= MOBILE_BREAKPOINT;
@@ -27472,7 +27485,7 @@
27472
27485
  request = request.clone({
27473
27486
  setHeaders: {
27474
27487
  'miam-origin': context.origin,
27475
- 'miam-front-version': '6.3.11',
27488
+ 'miam-front-version': '6.3.12',
27476
27489
  'miam-front-type': 'web',
27477
27490
  'miam-api-version': '4.7.0'
27478
27491
  }