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 0901c8b69b..03f6e50444 100644 --- a/src/app/core/cache/builders/remote-data-build.service.ts +++ b/src/app/core/cache/builders/remote-data-build.service.ts @@ -64,9 +64,10 @@ export class RemoteDataBuildService { .map((entry: ResponseCacheEntry) => ( entry.response).pageInfo) .distinctUntilChanged(); + //always use self link if that is cached, only if it isn't, get it via the response. const payload = - Observable.race( - this.objectCache.getBySelfLink(href, normalizedType), + Observable.combineLatest( + this.objectCache.getBySelfLink(href, normalizedType).startWith(undefined), responseCacheObs .filter((entry: ResponseCacheEntry) => entry.response.isSuccessful) .map((entry: ResponseCacheEntry) => ( entry.response).resourceUUIDs) @@ -79,8 +80,18 @@ export class RemoteDataBuildService { } }) .distinctUntilChanged() - ).map((normalized: TNormalized) => { - return this.build(normalized); + .startWith(undefined), + (fromSelfLink, fromResponse) => { + if (hasValue(fromSelfLink)) { + return fromSelfLink; + } + else { + return fromResponse; + } + } + ).filter(normalized => hasValue(normalized)) + .map((normalized: TNormalized) => { + return this.build(normalized); });