mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
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
This commit is contained in:
@@ -64,9 +64,10 @@ export class RemoteDataBuildService {
|
|||||||
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).pageInfo)
|
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).pageInfo)
|
||||||
.distinctUntilChanged();
|
.distinctUntilChanged();
|
||||||
|
|
||||||
|
//always use self link if that is cached, only if it isn't, get it via the response.
|
||||||
const payload =
|
const payload =
|
||||||
Observable.race(
|
Observable.combineLatest(
|
||||||
this.objectCache.getBySelfLink<TNormalized>(href, normalizedType),
|
this.objectCache.getBySelfLink<TNormalized>(href, normalizedType).startWith(undefined),
|
||||||
responseCacheObs
|
responseCacheObs
|
||||||
.filter((entry: ResponseCacheEntry) => entry.response.isSuccessful)
|
.filter((entry: ResponseCacheEntry) => entry.response.isSuccessful)
|
||||||
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).resourceUUIDs)
|
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).resourceUUIDs)
|
||||||
@@ -79,8 +80,18 @@ export class RemoteDataBuildService {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
).map((normalized: TNormalized) => {
|
.startWith(undefined),
|
||||||
return this.build<TNormalized, TDomain>(normalized);
|
(fromSelfLink, fromResponse) => {
|
||||||
|
if (hasValue(fromSelfLink)) {
|
||||||
|
return fromSelfLink;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return fromResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).filter(normalized => hasValue(normalized))
|
||||||
|
.map((normalized: TNormalized) => {
|
||||||
|
return this.build<TNormalized, TDomain>(normalized);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user