Skip to content
Snippets Groups Projects
Commit 0bccc7c2 authored by Art Lowel's avatar Art Lowel
Browse files

fixed an issue where sometimes the wrong resource would be returned if it was...

fixed an issue where sometimes the wrong resource would be returned if it was fetched as part of a list, and later queried as a single resource
parent 21a6a80d
Branches
Tags
No related merge requests found
......@@ -64,9 +64,10 @@ export class RemoteDataBuildService {
.map((entry: ResponseCacheEntry) => (<SuccessResponse> 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<TNormalized>(href, normalizedType),
Observable.combineLatest(
this.objectCache.getBySelfLink<TNormalized>(href, normalizedType).startWith(undefined),
responseCacheObs
.filter((entry: ResponseCacheEntry) => entry.response.isSuccessful)
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).resourceUUIDs)
......@@ -79,8 +80,18 @@ export class RemoteDataBuildService {
}
})
.distinctUntilChanged()
).map((normalized: TNormalized) => {
return this.build<TNormalized, TDomain>(normalized);
.startWith(undefined),
(fromSelfLink, fromResponse) => {
if (hasValue(fromSelfLink)) {
return fromSelfLink;
}
else {
return fromResponse;
}
}
).filter(normalized => hasValue(normalized))
.map((normalized: TNormalized) => {
return this.build<TNormalized, TDomain>(normalized);
});
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment