ng-miam 4.6.2 → 4.6.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.
- package/bundles/ng-miam.umd.js +70 -21
- package/bundles/ng-miam.umd.js.map +1 -1
- package/bundles/ng-miam.umd.min.js +2 -2
- package/bundles/ng-miam.umd.min.js.map +1 -1
- package/esm2015/lib/_components/like-button/like-button.component.js +2 -2
- package/esm2015/lib/_components/recipe-filters/recipe-filters.component.js +14 -11
- package/esm2015/lib/_services/context.service.js +2 -2
- package/esm2015/lib/_services/recipe-likes.service.js +39 -4
- package/esm2015/lib/_web-components/basket-preview/basket-preview-block/basket-preview-block.component.js +2 -2
- package/esm2015/lib/_web-components/catalog-list/catalog-list.component.js +3 -6
- package/esm2015/lib/_web-components/drawer/drawer.component.js +2 -2
- package/esm2015/lib/_web-components/recipe-catalog/recipe-catalog.component.js +3 -2
- package/fesm2015/ng-miam.js +57 -21
- package/fesm2015/ng-miam.js.map +1 -1
- package/lib/_services/context.service.d.ts +1 -1
- package/lib/_services/recipe-likes.service.d.ts +8 -0
- package/package.json +1 -1
package/bundles/ng-miam.umd.js
CHANGED
|
@@ -3054,9 +3054,19 @@
|
|
|
3054
3054
|
_this.resource = RecipeLike;
|
|
3055
3055
|
_this.type = 'recipe-likes';
|
|
3056
3056
|
_this.activeRecipeLikes = new Map();
|
|
3057
|
+
_this.MAX_RECIPE_LIKES_BEFORE_CLEAN = 200;
|
|
3058
|
+
_this.cleanUnobservedLikesIfNecessary = new i0.EventEmitter();
|
|
3059
|
+
_this.isCleaning = new rxjs.BehaviorSubject(false);
|
|
3060
|
+
_this.subscriptions = [];
|
|
3057
3061
|
_this.register();
|
|
3062
|
+
_this.subscriptions.push(_this.cleanUnobservedLikesIfNecessary.pipe(operators.tap(function (_) { return _this.isCleaning.next(true); }), operators.debounceTime(100)).subscribe(function (_) {
|
|
3063
|
+
_this.doCleanUnobservedLikesIfNecessary();
|
|
3064
|
+
}));
|
|
3058
3065
|
return _this;
|
|
3059
3066
|
}
|
|
3067
|
+
RecipeLikesService.prototype.ngOnDestroy = function () {
|
|
3068
|
+
this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
|
|
3069
|
+
};
|
|
3060
3070
|
RecipeLikesService.prototype.getLike = function (recipeId) {
|
|
3061
3071
|
this.addLikeToActivesIfNecessary(recipeId);
|
|
3062
3072
|
return this.activeRecipeLikes.get(recipeId);
|
|
@@ -3094,15 +3104,53 @@
|
|
|
3094
3104
|
this.activeRecipeLikes.delete(recipeId);
|
|
3095
3105
|
}
|
|
3096
3106
|
};
|
|
3107
|
+
RecipeLikesService.prototype.doCleanUnobservedLikesIfNecessary = function () {
|
|
3108
|
+
var e_1, _a;
|
|
3109
|
+
var _this = this;
|
|
3110
|
+
console.debug('[Miam] will check cleaning', this.activeRecipeLikes.size);
|
|
3111
|
+
if (this.activeRecipeLikes.size < this.MAX_RECIPE_LIKES_BEFORE_CLEAN) {
|
|
3112
|
+
this.isCleaning.next(false);
|
|
3113
|
+
return;
|
|
3114
|
+
}
|
|
3115
|
+
console.debug('[Miam] will clean unobserved recipes like');
|
|
3116
|
+
var keysToDelete = [];
|
|
3117
|
+
try {
|
|
3118
|
+
for (var _b = __values(this.activeRecipeLikes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3119
|
+
var _d = __read(_c.value, 2), recipeId = _d[0], activeLikes = _d[1];
|
|
3120
|
+
if (activeLikes && activeLikes.observers.length === 0) {
|
|
3121
|
+
keysToDelete.push(recipeId);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3126
|
+
finally {
|
|
3127
|
+
try {
|
|
3128
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3129
|
+
}
|
|
3130
|
+
finally { if (e_1) throw e_1.error; }
|
|
3131
|
+
}
|
|
3132
|
+
keysToDelete.forEach(function (recipeId) { return _this.activeRecipeLikes.delete(recipeId); });
|
|
3133
|
+
this.isCleaning.next(false);
|
|
3134
|
+
};
|
|
3097
3135
|
RecipeLikesService.prototype.addLikesToRecipes = function (recipes) {
|
|
3098
3136
|
var _this = this;
|
|
3099
3137
|
if (!this.userService.isLogged$.value) {
|
|
3100
3138
|
return rxjs.of(null);
|
|
3101
3139
|
}
|
|
3140
|
+
;
|
|
3141
|
+
return this.isCleaning.asObservable().pipe(operators.skipWhile(function (isCleaning) { return isCleaning; }), operators.take(1), operators.switchMap(function (_) { return _this.afterCLeanAddLikesToRecipes(recipes); }));
|
|
3142
|
+
};
|
|
3143
|
+
RecipeLikesService.prototype.afterCLeanAddLikesToRecipes = function (recipes) {
|
|
3144
|
+
var _this = this;
|
|
3145
|
+
var recipeIds = recipes.map(function (r) { return r.id; }).filter(function (rid) { return !_this.activeRecipeLikes.has(rid); });
|
|
3146
|
+
if (recipeIds.length == 0) {
|
|
3147
|
+
return rxjs.of(null);
|
|
3148
|
+
}
|
|
3149
|
+
;
|
|
3102
3150
|
return this.all({
|
|
3103
3151
|
page: { size: 20, number: 1 },
|
|
3104
3152
|
remotefilter: {
|
|
3105
|
-
recipe_id:
|
|
3153
|
+
recipe_id: recipeIds.join(),
|
|
3106
3154
|
is_past: 'true,false'
|
|
3107
3155
|
}
|
|
3108
3156
|
}).pipe(operators.skipWhile(function (resp) { return resp.is_loading; }), operators.tap(function (result) {
|
|
@@ -4341,7 +4389,7 @@
|
|
|
4341
4389
|
_this.onBasketAndPosSendEvent(_this.analyticsService.EVENT_PAYMENT_STARTED, totalPrice);
|
|
4342
4390
|
},
|
|
4343
4391
|
basket: {
|
|
4344
|
-
stats$: this.basketsService.basketStats
|
|
4392
|
+
stats$: this.basketsService.basketStats$.pipe(operators.skipWhile(function (stats) { return !stats; })),
|
|
4345
4393
|
basketIsReady$: this.basketsService.basketStats$.pipe(operators.skipWhile(function (stats) { return !stats; }), operators.take(1), operators.map(function () { return true; })),
|
|
4346
4394
|
entries$: this.basketsService.activeBasketEntries(),
|
|
4347
4395
|
confirm: function (totalPrice) { return _this.basketsService.confirmBasket(totalPrice); },
|
|
@@ -7843,7 +7891,7 @@
|
|
|
7843
7891
|
};
|
|
7844
7892
|
LikeButtonComponent.prototype.ngOnDestroy = function () {
|
|
7845
7893
|
this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
|
|
7846
|
-
this.recipeLikesService.
|
|
7894
|
+
this.recipeLikesService.cleanUnobservedLikesIfNecessary.emit();
|
|
7847
7895
|
};
|
|
7848
7896
|
LikeButtonComponent.prototype.currentPath = function () { return ''; };
|
|
7849
7897
|
LikeButtonComponent.prototype.initRecipeLike = function () {
|
|
@@ -8603,16 +8651,19 @@
|
|
|
8603
8651
|
return 'preferences';
|
|
8604
8652
|
};
|
|
8605
8653
|
RecipeFiltersComponent.prototype.ngOnChanges = function (changes) {
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
this.
|
|
8654
|
+
// Sometimes confirm() can send the component in a loop of onChanges triggers with no changes, so this would stop it
|
|
8655
|
+
if (changes.filters || changes.filterToRemove || changes.isFilterCollapsed || changes.position) {
|
|
8656
|
+
if (this.filterToRemove) {
|
|
8657
|
+
this.removeFilter(this.filterToRemove);
|
|
8658
|
+
}
|
|
8659
|
+
if (changes.isFilterCollapsed !== undefined && this.isMobile) {
|
|
8660
|
+
this.context.globalScrollableElement.style.overflow = this.isFilterCollapsed ? 'initial' : 'hidden';
|
|
8661
|
+
}
|
|
8662
|
+
this.recalculateRecipesCount();
|
|
8663
|
+
this.cdr.detectChanges();
|
|
8664
|
+
if (!this.isFilterCollapsed) {
|
|
8665
|
+
this.pageview();
|
|
8666
|
+
}
|
|
8616
8667
|
}
|
|
8617
8668
|
};
|
|
8618
8669
|
RecipeFiltersComponent.prototype.ngOnDestroy = function () {
|
|
@@ -10513,7 +10564,7 @@
|
|
|
10513
10564
|
_this.loading.next(false);
|
|
10514
10565
|
_this.cdr.detectChanges();
|
|
10515
10566
|
}),
|
|
10516
|
-
this.basketsService.basketStats$.pipe(operators.tap(function (stats) { return _this.statsUpdated.emit(stats); })).subscribe()
|
|
10567
|
+
this.basketsService.basketStats$.pipe(operators.skipWhile(function (stats) { return !stats; }), operators.tap(function (stats) { return _this.statsUpdated.emit(stats); })).subscribe()
|
|
10517
10568
|
];
|
|
10518
10569
|
};
|
|
10519
10570
|
BasketPreviewBlockComponent.prototype.ngOnChanges = function (changes) {
|
|
@@ -12958,11 +13009,8 @@
|
|
|
12958
13009
|
}
|
|
12959
13010
|
});
|
|
12960
13011
|
this.noMoreRecipes = results.length === 0;
|
|
12961
|
-
|
|
12962
|
-
return
|
|
12963
|
-
_this.retrievedRecipes.emit(_this.currentRecipes);
|
|
12964
|
-
return _this.currentRecipes;
|
|
12965
|
-
}));
|
|
13012
|
+
this.retrievedRecipes.emit(this.currentRecipes);
|
|
13013
|
+
return rxjs.of(this.currentRecipes);
|
|
12966
13014
|
}
|
|
12967
13015
|
else {
|
|
12968
13016
|
// tslint:disable-next-line: no-console
|
|
@@ -13919,7 +13967,7 @@
|
|
|
13919
13967
|
_this.pos = pos;
|
|
13920
13968
|
_this.assessValid();
|
|
13921
13969
|
})).subscribe());
|
|
13922
|
-
this.subscriptions.push(this.basketsService.basketStats$.pipe(operators.tap(function (stats) {
|
|
13970
|
+
this.subscriptions.push(this.basketsService.basketStats$.pipe(operators.skipWhile(function (stats) { return !stats; }), operators.tap(function (stats) {
|
|
13923
13971
|
_this.basketStats = stats;
|
|
13924
13972
|
_this.cdr.detectChanges();
|
|
13925
13973
|
})).subscribe());
|
|
@@ -15810,7 +15858,7 @@
|
|
|
15810
15858
|
_this.supplierId = supplier.id;
|
|
15811
15859
|
return _this.loadPackages();
|
|
15812
15860
|
})).subscribe(),
|
|
15813
|
-
this.basketsService.basketStats$.subscribe(function (bs) {
|
|
15861
|
+
this.basketsService.basketStats$.pipe(operators.skipWhile(function (bs) { return !bs; })).subscribe(function (bs) {
|
|
15814
15862
|
_this.recipeCount = bs.recipesCount;
|
|
15815
15863
|
_this.totalPrice = bs.totalPrice;
|
|
15816
15864
|
_this.cdr.detectChanges();
|
|
@@ -15858,6 +15906,7 @@
|
|
|
15858
15906
|
this.filters.additionalFilters = null;
|
|
15859
15907
|
};
|
|
15860
15908
|
RecipeCatalogComponent.prototype.updateFilters = function (filters) {
|
|
15909
|
+
console.log('updateFilters');
|
|
15861
15910
|
this.filters = filters.copy(); // necessary to trigger child component change
|
|
15862
15911
|
this.filterToRemove = undefined;
|
|
15863
15912
|
this.returnToTop();
|