ng-miam 8.5.7 → 8.5.8

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.
@@ -3900,6 +3900,7 @@
3900
3900
  _this.basketIsFetching = false;
3901
3901
  _this.basketPreviewIsCalculating = false;
3902
3902
  _this.basketInitCalled = false;
3903
+ _this.confirming = new rxjs.BehaviorSubject(false);
3903
3904
  _this.basketActionsQueue = new rxjs.BehaviorSubject([]);
3904
3905
  _this._entries$ = new rxjs.BehaviorSubject([]);
3905
3906
  _this.actionsBeingProcessed = new rxjs.BehaviorSubject([]);
@@ -4138,13 +4139,14 @@
4138
4139
  */
4139
4140
  BasketsService.prototype.confirmPaymentAndBasket = function (totalPrice) {
4140
4141
  var _this = this;
4142
+ this.confirming.next(true);
4141
4143
  return this.waitForBasket.pipe(operators.switchMap(function (basket) {
4142
4144
  if (+totalPrice > 0 && basket.totalPrice > 0) {
4143
4145
  _this.analyticsService.sendEventWhenReady(_this.analyticsService.EVENT_PAYMENT_CONFIRMED, null, _this.eventProps(basket, totalPrice));
4144
4146
  return _this.confirmBasket(basket, totalPrice);
4145
4147
  }
4146
4148
  return _this._basket$;
4147
- }));
4149
+ }), operators.tap(function () { return _this.confirming.next(false); }));
4148
4150
  };
4149
4151
  /**
4150
4152
  * Tries to confirm basket. Sends analytic event and refresh current basket on successfull confirmation
@@ -5116,6 +5118,7 @@
5116
5118
  this.supplierService = supplierService;
5117
5119
  this.ignoreUpdatesFromMiam = false;
5118
5120
  this.firstMiamBasketProcess = true;
5121
+ this.lockWhileConfirming = new rxjs.BehaviorSubject(false);
5119
5122
  /**
5120
5123
  * This method needs to be passed to Miam by the retailer
5121
5124
  */
@@ -5125,6 +5128,7 @@
5125
5128
  };
5126
5129
  // Begin listening for miam's basket (will not fetch basket automatically)
5127
5130
  this.supplierService.supplier$.pipe(operators.skipWhile(function (s) { return !s; }), operators.take(1), operators.tap(function () {
5131
+ _this.listenToConfirm();
5128
5132
  _this.listenToMiam();
5129
5133
  })).subscribe();
5130
5134
  }
@@ -5144,6 +5148,19 @@
5144
5148
  enumerable: false,
5145
5149
  configurable: true
5146
5150
  });
5151
+ /**
5152
+ * When basketsService.confirming's last emitted value was true and current emitted value is false,
5153
+ * Reset basket-sync
5154
+ */
5155
+ BasketsSynchronizerService.prototype.listenToConfirm = function () {
5156
+ var _this = this;
5157
+ this.basketsService.confirming.pipe(operators.skipWhile(function (confirming) { return confirming === _this.lockWhileConfirming.value; })).subscribe(function (confirming) {
5158
+ if (!confirming && _this.lockWhileConfirming.value) {
5159
+ _this.resetMiam();
5160
+ }
5161
+ _this.lockWhileConfirming.next(confirming);
5162
+ });
5163
+ };
5147
5164
  /**
5148
5165
  * Start listening on Miam's basket
5149
5166
  */
@@ -5305,14 +5322,17 @@
5305
5322
  * @param retailerBasket current basket of the retailer
5306
5323
  */
5307
5324
  BasketsSynchronizerService.prototype.retailerBasketChanged = function (retailerBasket) {
5325
+ var _this = this;
5308
5326
  // eslint-disable-next-line no-console
5309
5327
  console.debug("[Miam] Update received from retailer\n - " + JSON.stringify(retailerBasket) + "\n - First retailer basket was : " + JSON.stringify(this.firstRetailerBasket));
5310
- if (!this.isReady()) {
5311
- return this.initFirstRetailerBasket(retailerBasket);
5312
- }
5313
- this.isProcessingRetailerEvent = true;
5314
- var toRemoveFromMiam = this.comparatorService.updateReceivedFromRetailer(retailerBasket);
5315
- this.sendUpdateToMiam(toRemoveFromMiam);
5328
+ this.lockWhileConfirming.pipe(operators.skipWhile(function (locked) { return locked; }), operators.take(1)).subscribe(function () {
5329
+ if (!_this.isReady()) {
5330
+ return _this.initFirstRetailerBasket(retailerBasket);
5331
+ }
5332
+ _this.isProcessingRetailerEvent = true;
5333
+ var toRemoveFromMiam = _this.comparatorService.updateReceivedFromRetailer(retailerBasket);
5334
+ _this.sendUpdateToMiam(toRemoveFromMiam);
5335
+ });
5316
5336
  };
5317
5337
  /**
5318
5338
  * Handle Payment and confirm Miam's basket before restarting the synchronization by resetting retailer's basket
@@ -8572,7 +8592,7 @@
8572
8592
  MiamInterceptor.prototype.setMiamHeaders = function (request) {
8573
8593
  var headersToAdd = {
8574
8594
  'miam-origin': this.context.origin.value,
8575
- 'miam-front-version': '8.5.7',
8595
+ 'miam-front-version': '8.5.8',
8576
8596
  'miam-front-type': 'web',
8577
8597
  'miam-api-version': '4.7.0'
8578
8598
  };