@osovitny/anatoly 2.1.10 → 2.1.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.
@@ -1650,8 +1650,15 @@
1650
1650
  _this.baseUrl = '/api/appContext';
1651
1651
  return _this;
1652
1652
  }
1653
- AppContextService.prototype.updateContextIfExpired = function () {
1654
- var context = this.sessionStorage.getObject(this.storageKeyName);
1653
+ //Session
1654
+ AppContextService.prototype.getCurrentFromSession = function () {
1655
+ return this.sessionStorage.getObject(this.storageKeyName);
1656
+ };
1657
+ AppContextService.prototype.setCurrentFromSession = function (value) {
1658
+ this.sessionStorage.setObject(this.storageKeyName, value);
1659
+ };
1660
+ AppContextService.prototype.updateCurrentIfExpired = function () {
1661
+ var context = this.getCurrentFromSession();
1655
1662
  if (!context) {
1656
1663
  return;
1657
1664
  }
@@ -1661,7 +1668,7 @@
1661
1668
  var lastRequested = new Date(context.lastRequested);
1662
1669
  var in2Mins = new Date(lastRequested.getFullYear(), lastRequested.getMonth(), lastRequested.getDate(), lastRequested.getHours(), lastRequested.getMinutes() + 2, 0, 0);
1663
1670
  if (in2Mins.getTime() < now.getTime()) {
1664
- this.updateCurrentContext();
1671
+ this.updateCurrent();
1665
1672
  }
1666
1673
  }
1667
1674
  };
@@ -1676,16 +1683,15 @@
1676
1683
  this.successes = [];
1677
1684
  this.subscription.unsubscribe();
1678
1685
  this.subscription = null;
1679
- this.current = null;
1680
1686
  };
1681
1687
  AppContextService.prototype.getCurrent = function (success, getCachedIfExist) {
1682
1688
  var _this = this;
1683
1689
  if (success === void 0) { success = null; }
1684
1690
  if (getCachedIfExist === void 0) { getCachedIfExist = true; }
1685
- var current = this.current;
1686
- if (getCachedIfExist && current != null) {
1691
+ var context = this.getCurrentFromSession();
1692
+ if (getCachedIfExist && context != null) {
1687
1693
  if (success) {
1688
- success(current);
1694
+ success(context);
1689
1695
  }
1690
1696
  return;
1691
1697
  }
@@ -1702,11 +1708,11 @@
1702
1708
  }, function (e) {
1703
1709
  });
1704
1710
  };
1705
- AppContextService.prototype.updateCurrentContext = function (success) {
1711
+ AppContextService.prototype.updateCurrent = function (success) {
1706
1712
  if (success === void 0) { success = null; }
1707
1713
  this.getCurrent(success, false);
1708
1714
  };
1709
- AppContextService.prototype.clearCurrentContex = function () {
1715
+ AppContextService.prototype.clearCurrent = function () {
1710
1716
  this.sessionStorage.remove(this.storageKeyName);
1711
1717
  };
1712
1718
  AppContextService.prototype.isUserSignedIn = function () {
@@ -1716,13 +1722,14 @@
1716
1722
  return ContextInitState.isUserAdmin;
1717
1723
  };
1718
1724
  Object.defineProperty(AppContextService.prototype, "current", {
1725
+ //Properties
1719
1726
  //current
1720
1727
  get: function () {
1721
- this.updateContextIfExpired();
1722
- return this.sessionStorage.getObject(this.storageKeyName);
1728
+ this.updateCurrentIfExpired();
1729
+ return this.getCurrentFromSession();
1723
1730
  },
1724
1731
  set: function (value) {
1725
- this.sessionStorage.setObject(this.storageKeyName, value);
1732
+ this.setCurrentFromSession(value);
1726
1733
  },
1727
1734
  enumerable: false,
1728
1735
  configurable: true
@@ -2542,8 +2549,8 @@
2542
2549
  </file>
2543
2550
  */
2544
2551
  var BuyAccessButtonComponent = /** @class */ (function () {
2545
- function BuyAccessButtonComponent(appcontext, api) {
2546
- this.appcontext = appcontext;
2552
+ function BuyAccessButtonComponent(appContext, api) {
2553
+ this.appContext = appContext;
2547
2554
  this.api = api;
2548
2555
  this.contextUpdated = false;
2549
2556
  this.isUserSignedIn = false;
@@ -2552,11 +2559,11 @@
2552
2559
  }
2553
2560
  BuyAccessButtonComponent.prototype.ngOnInit = function () {
2554
2561
  var _this = this;
2555
- if (!this.appcontext.isUserSignedIn()) {
2562
+ if (!this.appContext.isUserSignedIn()) {
2556
2563
  this.contextUpdated = true;
2557
2564
  return;
2558
2565
  }
2559
- this.appcontext.getCurrent(function (current) {
2566
+ this.appContext.getCurrent(function (current) {
2560
2567
  _this.isUserSignedIn = current.isUserSignedIn;
2561
2568
  if (_this.isUserSignedIn) {
2562
2569
  _this.currentPlan = current.account.billingPlan;