ntk-cms-api 1.2.238 → 1.2.240

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.
@@ -1275,6 +1275,15 @@ class ApiServerBase {
1275
1275
  localStorage.setItem(this.keyBaseUrl, url);
1276
1276
  this.configApiRetry = apiRetry;
1277
1277
  }
1278
+ cashApiIsValid(serviceNameKay) {
1279
+ if (!this.cachApiResult[serviceNameKay])
1280
+ return false;
1281
+ if (!this.cachApiResult[serviceNameKay].isSuccess)
1282
+ return true;
1283
+ if (this.cachApiResult[serviceNameKay].dateResult && (new Date().getTime() - this.cachApiResult[serviceNameKay].dateResult) < this.cashApiSeconds)
1284
+ return true;
1285
+ return false;
1286
+ }
1278
1287
  childConstructor() {
1279
1288
  // test
1280
1289
  }
@@ -1679,14 +1688,10 @@ class ApiCmsServerBase extends ApiServerBase {
1679
1688
  const serviceName = 'ServiceGetOneById';
1680
1689
  const serviceNameKay = serviceName + '_' + id;
1681
1690
  if (this.getModuleCashService().includes(serviceName)) {
1682
- if (this.cachApiResult[serviceNameKay]?.isSuccess && (new Date().getTime() - this.cachApiCallDate[serviceNameKay].getTime()) < this.cashApiSeconds)
1683
- return of(this.cachApiResult[serviceNameKay]);
1684
- if (this.cachApiResult[serviceNameKay].isSuccess && (new Date().getTime() - this.cachApiCallDate[serviceNameKay].getTime()) < this.cashApiSeconds)
1685
- this.cachApiResult[serviceNameKay] = null;
1686
- while (this.cachApiCallDate[serviceNameKay] && (new Date().getTime() - this.cachApiCallDate[serviceNameKay].getTime()) < this.cashApiSeconds) {
1687
- if (this.cachApiResult[serviceNameKay]?.isSuccess)
1691
+ do {
1692
+ if (this.cashApiIsValid(serviceNameKay))
1688
1693
  return of(this.cachApiResult[serviceNameKay]);
1689
- }
1694
+ } while (this.cachApiCallDate[serviceNameKay] && (new Date().getTime() - this.cachApiCallDate[serviceNameKay].getTime()) < this.cashApiSeconds);
1690
1695
  this.cachApiCallDate[serviceNameKay] = new Date();
1691
1696
  }
1692
1697
  //! optimaze call api
@@ -1699,8 +1704,10 @@ class ApiCmsServerBase extends ApiServerBase {
1699
1704
  // catchError(this.handleError)
1700
1705
  map((ret) => {
1701
1706
  //! optimaze call api
1702
- if (this.getModuleCashService().includes(serviceName))
1707
+ if (this.getModuleCashService().includes(serviceName)) {
1703
1708
  this.cachApiResult[serviceNameKay] = ret;
1709
+ this.cachApiResult[serviceNameKay].dateResult = new Date();
1710
+ }
1704
1711
  //! optimaze call api
1705
1712
  return this.errorExceptionResultCheck(ret);
1706
1713
  }));