mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
solved issue where the items werent reloaded after updating the relationship
This commit is contained in:
@@ -161,6 +161,7 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findByHref(href: string, options?: HttpOptions): Observable<RemoteData<T>> {
|
findByHref(href: string, options?: HttpOptions): Observable<RemoteData<T>> {
|
||||||
|
console.log('perform request for:', href)
|
||||||
this.requestService.configure(new GetRequest(this.requestService.generateRequestId(), href, null, options), this.forceBypassCache);
|
this.requestService.configure(new GetRequest(this.requestService.generateRequestId(), href, null, options), this.forceBypassCache);
|
||||||
return this.rdbService.buildSingle<T>(href);
|
return this.rdbService.buildSingle<T>(href);
|
||||||
}
|
}
|
||||||
|
@@ -106,7 +106,6 @@ export class RelationshipService extends DataService<Relationship> {
|
|||||||
),
|
),
|
||||||
take(1)
|
take(1)
|
||||||
).subscribe(([item1, item2]) => {
|
).subscribe(([item1, item2]) => {
|
||||||
console.log(item1, item2);
|
|
||||||
this.removeRelationshipItemsFromCache(item1);
|
this.removeRelationshipItemsFromCache(item1);
|
||||||
this.removeRelationshipItemsFromCache(item2);
|
this.removeRelationshipItemsFromCache(item2);
|
||||||
})
|
})
|
||||||
@@ -115,11 +114,12 @@ export class RelationshipService extends DataService<Relationship> {
|
|||||||
private removeRelationshipItemsFromCache(item) {
|
private removeRelationshipItemsFromCache(item) {
|
||||||
this.objectCache.remove(item.self);
|
this.objectCache.remove(item.self);
|
||||||
this.requestService.removeByHrefSubstring(item.self);
|
this.requestService.removeByHrefSubstring(item.self);
|
||||||
this.objectCache.hasBySelfLinkObservable(item.self).pipe(
|
combineLatest(
|
||||||
tap((exists) => console.log('exists: ', exists, 'uuid', item.uuid)),
|
this.objectCache.hasBySelfLinkObservable(item.self),
|
||||||
filter((exists) => !exists),
|
this.requestService.hasByHrefObservable(item.self)
|
||||||
|
).pipe(
|
||||||
|
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
|
||||||
take(1),
|
take(1),
|
||||||
tap((exists) => console.log('still exists: ', exists, 'uuid', item.uuid)),
|
|
||||||
switchMap(() => this.itemService.findByHref(item.self).pipe(take(1)))
|
switchMap(() => this.itemService.findByHref(item.self).pipe(take(1)))
|
||||||
).subscribe();
|
).subscribe();
|
||||||
}
|
}
|
||||||
@@ -254,11 +254,6 @@ export class RelationshipService extends DataService<Relationship> {
|
|||||||
|
|
||||||
|
|
||||||
getRelationshipByItemsAndLabel(item1: Item, item2: Item, label: string): Observable<Relationship> {
|
getRelationshipByItemsAndLabel(item1: Item, item2: Item, label: string): Observable<Relationship> {
|
||||||
console.log('item 1: ', this.objectCache.hasByUUID(item1.uuid));
|
|
||||||
console.log('item 1 uuid: ', item1.uuid);
|
|
||||||
console.log('item 2: ', this.objectCache.hasByUUID(item2.uuid));
|
|
||||||
console.log('item 2 uuid: ', item2.uuid);
|
|
||||||
|
|
||||||
return this.getItemRelationshipsByLabel(item1, label)
|
return this.getItemRelationshipsByLabel(item1, label)
|
||||||
.pipe(
|
.pipe(
|
||||||
mergeMap((relationships: Relationship[]) => {
|
mergeMap((relationships: Relationship[]) => {
|
||||||
@@ -273,7 +268,6 @@ export class RelationshipService extends DataService<Relationship> {
|
|||||||
}))
|
}))
|
||||||
}),
|
}),
|
||||||
map((relationships: Relationship[]) => relationships.find((relationship => hasValue(relationship)))),
|
map((relationships: Relationship[]) => relationships.find((relationship => hasValue(relationship)))),
|
||||||
tap((relationships) => console.log(relationships)),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user