http-request-manager 18.13.26 → 18.13.27
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.
|
@@ -7077,10 +7077,12 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7077
7077
|
const tableDef = TableSchemaDef.adapt({ table: this.databaseOptions.table, schema: expectedSchema });
|
|
7078
7078
|
return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(switchMap(() => this.dbManagerService.createDatabaseTable(tableDef)), switchMap(() => fetchFromAPI()));
|
|
7079
7079
|
}
|
|
7080
|
-
const
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7080
|
+
const hasTrackerConfig = Array.isArray(options?.watchParams) && options.watchParams.length > 0;
|
|
7081
|
+
if (hasTrackerConfig) {
|
|
7082
|
+
const trackerAllowsRequest = this.queryParamsTrackerService.checkRequestOptions(this.resolvePath(effectiveParams), this.buildQueryTrackerOptions(options));
|
|
7083
|
+
if (trackerAllowsRequest) {
|
|
7084
|
+
return fetchFromAPI();
|
|
7085
|
+
}
|
|
7084
7086
|
}
|
|
7085
7087
|
return this.dbManagerService.getTableRecords(this.databaseOptions.table).pipe(switchMap((dbData) => {
|
|
7086
7088
|
if (Array.isArray(dbData) && dbData.length > 0) {
|
|
@@ -7264,24 +7266,26 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7264
7266
|
if (hasExpired) {
|
|
7265
7267
|
return this.dbManagerService.clearTable(this.databaseOptions.table).pipe(tap(() => this.setCachedRequestSignature(this.databaseOptions.table, 'STREAM', requestSignature)), switchMap(() => this.httpManagerService.getRequest(requestOptions, effectiveParams)), map((apiData) => ({ data: apiData, fromCache: false })));
|
|
7266
7268
|
}
|
|
7267
|
-
const
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7269
|
+
const hasTrackerConfig = Array.isArray(options?.watchParams) && options.watchParams.length > 0;
|
|
7270
|
+
if (hasTrackerConfig) {
|
|
7271
|
+
const trackerAllowsRequest = this.queryParamsTrackerService.checkRequestOptions(this.resolvePath(effectiveParams), this.buildQueryTrackerOptions(options));
|
|
7272
|
+
if (!trackerAllowsRequest) {
|
|
7273
|
+
return this.dbManagerService.getTableRecords(this.databaseOptions.table).pipe(switchMap((dbData) => {
|
|
7274
|
+
if (Array.isArray(dbData) && dbData.length > 0) {
|
|
7275
|
+
return of({ data: dbData, fromCache: true });
|
|
7276
|
+
}
|
|
7277
|
+
const currentStateData = this.get()?.data;
|
|
7278
|
+
if (Array.isArray(currentStateData) && currentStateData.length > 0) {
|
|
7279
|
+
return of({ data: currentStateData, fromCache: true });
|
|
7280
|
+
}
|
|
7281
|
+
if (currentStateData &&
|
|
7282
|
+
!Array.isArray(currentStateData) &&
|
|
7283
|
+
Object.keys(currentStateData).length > 0) {
|
|
7284
|
+
return of({ data: currentStateData, fromCache: true });
|
|
7285
|
+
}
|
|
7286
|
+
return of({ data: this.dataType === DataType.ARRAY ? [] : {}, fromCache: true });
|
|
7287
|
+
}));
|
|
7288
|
+
}
|
|
7285
7289
|
}
|
|
7286
7290
|
this.setCachedRequestSignature(this.databaseOptions.table, 'STREAM', requestSignature);
|
|
7287
7291
|
return this.httpManagerService.getRequest(requestOptions, effectiveParams).pipe(map((apiData) => ({ data: apiData, fromCache: false })));
|