diff --git a/src/app/core/cache/builders/remote-data-build.service.ts b/src/app/core/cache/builders/remote-data-build.service.ts index 0a1ba0b9e0..16da33cb2e 100644 --- a/src/app/core/cache/builders/remote-data-build.service.ts +++ b/src/app/core/cache/builders/remote-data-build.service.ts @@ -113,6 +113,7 @@ export class RemoteDataBuildService { href$ = observableOf(href$); } + href$.subscribe(href => console.log('request url: ', href)); const requestEntry$ = href$.pipe(getRequestFromRequestHref(this.requestService)); const tDomainList$ = requestEntry$.pipe( getResourceLinksFromResponse(), diff --git a/src/app/core/data/data.service.ts b/src/app/core/data/data.service.ts index 072946669b..552a8157c5 100644 --- a/src/app/core/data/data.service.ts +++ b/src/app/core/data/data.service.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { distinctUntilChanged, filter, find, first, map, mergeMap, switchMap, take } from 'rxjs/operators'; +import { distinctUntilChanged, filter, find, first, map, mergeMap, switchMap, take, tap } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util'; @@ -184,20 +184,20 @@ export abstract class DataService { * @return {Observable>} * Return an observable that emits response from the server */ - protected searchBy(searchMethod: string, options: FindAllOptions = {}, refresh: boolean = false): Observable>> { + protected searchBy(searchMethod: string, options: FindAllOptions = {}): Observable>> { const hrefObs = this.getSearchByHref(searchMethod, options); - hrefObs.pipe( - find((href: string) => hasValue(href))) - .subscribe((href: string) => { - if (refresh) { + return hrefObs.pipe( + find((href: string) => hasValue(href)), + switchMap((href: string) => { this.requestService.removeByHrefSubstring(href); + const request = new FindAllRequest(this.requestService.generateRequestId(), href, options); + this.requestService.configure(request, true); + return this.rdbService.buildList(href) as Observable>> } - const request = new FindAllRequest(this.requestService.generateRequestId(), href, options); - this.requestService.configure(request, true); - }); - return this.rdbService.buildList(hrefObs) as Observable>>; + ) + ); } /** diff --git a/src/app/core/data/relationship.service.ts b/src/app/core/data/relationship.service.ts index d2a8f92775..7c28d432a6 100644 --- a/src/app/core/data/relationship.service.ts +++ b/src/app/core/data/relationship.service.ts @@ -225,7 +225,7 @@ export class RelationshipService extends DataService { } else { findAllOptions.searchParams = searchParams; } - return this.searchBy('byLabel', findAllOptions, true); + return this.searchBy('byLabel', findAllOptions); } /** diff --git a/src/app/core/data/request.service.ts b/src/app/core/data/request.service.ts index 00bae3c0ef..739f0f72b8 100644 --- a/src/app/core/data/request.service.ts +++ b/src/app/core/data/request.service.ts @@ -3,7 +3,7 @@ import { HttpHeaders } from '@angular/common/http'; import { createSelector, MemoizedSelector, select, Store } from '@ngrx/store'; import { Observable, race as observableRace } from 'rxjs'; -import { filter, map, mergeMap, take } from 'rxjs/operators'; +import { filter, map, mergeMap, switchMap, take } from 'rxjs/operators'; import { cloneDeep, remove } from 'lodash'; import { AppState } from '../../app.reducer';