100302: Add support to check if a request has a cached value

This commit is contained in:
Yana De Pauw
2023-03-28 14:38:44 +02:00
parent 153a53f118
commit 9f6616a5ce
6 changed files with 129 additions and 17 deletions

View File

@@ -188,17 +188,12 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
this.retrieveExternalSourcesSub = this.reload$.pipe(
filter((sourceQueryObject: ExternalSourceData) => isNotEmpty(sourceQueryObject.sourceId) && isNotEmpty(sourceQueryObject.query)),
switchMap((sourceQueryObject: ExternalSourceData) => {
const currentEntry = this.entriesRD$.getValue();
let useCache = true;
if (hasValue(currentEntry) && currentEntry.isError) {
useCache = false;
}
const query = sourceQueryObject.query;
this.routeData = sourceQueryObject;
return this.searchConfigService.paginatedSearchOptions.pipe(
tap(() => this.isLoading$.next(true)),
filter((searchOptions) => searchOptions.query === query),
mergeMap((searchOptions) => this.externalService.getExternalSourceEntries(this.routeData.sourceId, searchOptions, useCache).pipe(
mergeMap((searchOptions) => this.externalService.getExternalSourceEntries(this.routeData.sourceId, searchOptions).pipe(
getFinishedRemoteData(),
))
);