mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 13:33:03 +00:00
93889: Fixed issue with DataService.deleteByHref where the success response would not be emitted if it were set to stale first
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
import { AsyncSubject, combineLatest, from as observableFrom, Observable, of as observableOf } from 'rxjs';
|
import { AsyncSubject, from as observableFrom, Observable, of as observableOf } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
filter,
|
filter,
|
||||||
@@ -166,7 +166,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
|||||||
*/
|
*/
|
||||||
buildHrefWithParams(href: string, params: RequestParam[], ...linksToFollow: FollowLinkConfig<T>[]): string {
|
buildHrefWithParams(href: string, params: RequestParam[], ...linksToFollow: FollowLinkConfig<T>[]): string {
|
||||||
|
|
||||||
let args = [];
|
let args = [];
|
||||||
if (hasValue(params)) {
|
if (hasValue(params)) {
|
||||||
params.forEach((param: RequestParam) => {
|
params.forEach((param: RequestParam) => {
|
||||||
args = this.addHrefArg(href, args, `${param.fieldName}=${param.fieldValue}`);
|
args = this.addHrefArg(href, args, `${param.fieldName}=${param.fieldValue}`);
|
||||||
@@ -181,6 +181,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
|||||||
return href;
|
return href;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the embed options to the link for the request
|
* Adds the embed options to the link for the request
|
||||||
* @param href The href the params are to be added to
|
* @param href The href the params are to be added to
|
||||||
@@ -487,7 +488,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
createPatchFromCache(object: T): Observable<Operation[]> {
|
createPatchFromCache(object: T): Observable<Operation[]> {
|
||||||
const oldVersion$ = this.findByHref(object._links.self.href, true, false);
|
const oldVersion$ = this.findByHref(object._links.self.href, true, false);
|
||||||
return oldVersion$.pipe(
|
return oldVersion$.pipe(
|
||||||
getFirstSucceededRemoteData(),
|
getFirstSucceededRemoteData(),
|
||||||
getRemoteDataPayload(),
|
getRemoteDataPayload(),
|
||||||
@@ -665,9 +666,17 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
|||||||
invalidated$.complete();
|
invalidated$.complete();
|
||||||
});
|
});
|
||||||
|
|
||||||
return combineLatest([response$, invalidated$]).pipe(
|
return response$.pipe(
|
||||||
filter(([_, invalidated]) => invalidated),
|
switchMap((rd: RemoteData<NoContent>) => {
|
||||||
map(([response, _]) => response),
|
if (rd.hasSucceeded) {
|
||||||
|
return invalidated$.pipe(
|
||||||
|
filter((invalidated: boolean) => invalidated),
|
||||||
|
map(() => rd)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return [rd];
|
||||||
|
}
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user