ng-miam 8.7.3 → 8.7.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.
@@ -4130,6 +4130,7 @@
4130
4130
  _this.basketIsFetching = false;
4131
4131
  _this.basketPreviewIsCalculating = false;
4132
4132
  _this.basketInitCalled = false;
4133
+ _this.confirming = new rxjs.BehaviorSubject(false);
4133
4134
  _this.basketActionsQueue = new rxjs.BehaviorSubject([]);
4134
4135
  _this._entries$ = new rxjs.BehaviorSubject([]);
4135
4136
  _this.actionsBeingProcessed = new rxjs.BehaviorSubject([]);
@@ -4362,13 +4363,14 @@
4362
4363
  */
4363
4364
  BasketsService.prototype.confirmPaymentAndBasket = function (totalPrice) {
4364
4365
  var _this = this;
4366
+ this.confirming.next(true);
4365
4367
  return this.waitForBasket.pipe(operators.switchMap(function (basket) {
4366
4368
  if (+totalPrice > 0 && basket.totalPrice > 0) {
4367
4369
  _this.analyticsService.sendEventWhenReady(_this.analyticsService.EVENT_PAYMENT_CONFIRMED, null, _this.eventProps(basket, totalPrice));
4368
4370
  return _this.confirmBasket(basket, totalPrice);
4369
4371
  }
4370
4372
  return _this._basket$;
4371
- }));
4373
+ }), operators.tap(function () { return _this.confirming.next(false); }));
4372
4374
  };
4373
4375
  /**
4374
4376
  * Tries to confirm basket. Sends analytic event and refresh current basket on successfull confirmation
@@ -5339,6 +5341,7 @@
5339
5341
  this.supplierService = supplierService;
5340
5342
  this.ignoreUpdatesFromMiam = false;
5341
5343
  this.firstMiamBasketProcess = true;
5344
+ this.lockWhileConfirming = new rxjs.BehaviorSubject(false);
5342
5345
  /**
5343
5346
  * This method needs to be passed to Miam by the retailer
5344
5347
  */
@@ -5348,6 +5351,7 @@
5348
5351
  };
5349
5352
  // Begin listening for miam's basket (will not fetch basket automatically)
5350
5353
  this.supplierService.supplier$.pipe(operators.skipWhile(function (s) { return !s; }), operators.take(1), operators.tap(function () {
5354
+ _this.listenToConfirm();
5351
5355
  _this.listenToMiam();
5352
5356
  })).subscribe();
5353
5357
  }
@@ -5367,6 +5371,19 @@
5367
5371
  enumerable: false,
5368
5372
  configurable: true
5369
5373
  });
5374
+ /**
5375
+ * When basketsService.confirming's last emitted value was true and current emitted value is false,
5376
+ * Reset basket-sync
5377
+ */
5378
+ BasketsSynchronizerService.prototype.listenToConfirm = function () {
5379
+ var _this = this;
5380
+ this.basketsService.confirming.pipe(operators.skipWhile(function (confirming) { return confirming === _this.lockWhileConfirming.value; })).subscribe(function (confirming) {
5381
+ if (!confirming && _this.lockWhileConfirming.value) {
5382
+ _this.resetMiam();
5383
+ }
5384
+ _this.lockWhileConfirming.next(confirming);
5385
+ });
5386
+ };
5370
5387
  /**
5371
5388
  * Start listening on Miam's basket
5372
5389
  */
@@ -5528,14 +5545,17 @@
5528
5545
  * @param retailerBasket current basket of the retailer
5529
5546
  */
5530
5547
  BasketsSynchronizerService.prototype.retailerBasketChanged = function (retailerBasket) {
5548
+ var _this = this;
5531
5549
  // eslint-disable-next-line no-console
5532
5550
  console.debug("[Miam] Update received from retailer\n - " + JSON.stringify(retailerBasket) + "\n - First retailer basket was : " + JSON.stringify(this.firstRetailerBasket));
5533
- if (!this.isReady()) {
5534
- return this.initFirstRetailerBasket(retailerBasket);
5535
- }
5536
- this.isProcessingRetailerEvent = true;
5537
- var toRemoveFromMiam = this.comparatorService.updateReceivedFromRetailer(retailerBasket);
5538
- this.sendUpdateToMiam(toRemoveFromMiam);
5551
+ this.lockWhileConfirming.pipe(operators.skipWhile(function (locked) { return locked; }), operators.take(1)).subscribe(function () {
5552
+ if (!_this.isReady()) {
5553
+ return _this.initFirstRetailerBasket(retailerBasket);
5554
+ }
5555
+ _this.isProcessingRetailerEvent = true;
5556
+ var toRemoveFromMiam = _this.comparatorService.updateReceivedFromRetailer(retailerBasket);
5557
+ _this.sendUpdateToMiam(toRemoveFromMiam);
5558
+ });
5539
5559
  };
5540
5560
  /**
5541
5561
  * Handle Payment and confirm Miam's basket before restarting the synchronization by resetting retailer's basket
@@ -8812,7 +8832,7 @@
8812
8832
  MiamInterceptor.prototype.setMiamHeaders = function (request) {
8813
8833
  var headersToAdd = {
8814
8834
  'miam-origin': this.context.origin.value,
8815
- 'miam-front-version': '8.7.3',
8835
+ 'miam-front-version': '8.7.4',
8816
8836
  'miam-front-type': 'web',
8817
8837
  'miam-api-version': '4.7.0'
8818
8838
  };