From 37072dc01ed6e8199ba1301b4bb78b1a747a89d9 Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 22 Aug 2019 09:05:44 +0200 Subject: [PATCH] solved issue where the items werent reloaded after updating the relationship --- src/app/core/data/data.service.ts | 1 + src/app/core/data/relationship.service.ts | 16 +++++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/app/core/data/data.service.ts b/src/app/core/data/data.service.ts index fc4da69a5c..e91143a8cf 100644 --- a/src/app/core/data/data.service.ts +++ b/src/app/core/data/data.service.ts @@ -161,6 +161,7 @@ export abstract class DataService { } findByHref(href: string, options?: HttpOptions): Observable> { + console.log('perform request for:', href) this.requestService.configure(new GetRequest(this.requestService.generateRequestId(), href, null, options), this.forceBypassCache); return this.rdbService.buildSingle(href); } diff --git a/src/app/core/data/relationship.service.ts b/src/app/core/data/relationship.service.ts index 9b4bf04997..b93f4f6ea4 100644 --- a/src/app/core/data/relationship.service.ts +++ b/src/app/core/data/relationship.service.ts @@ -106,7 +106,6 @@ export class RelationshipService extends DataService { ), take(1) ).subscribe(([item1, item2]) => { - console.log(item1, item2); this.removeRelationshipItemsFromCache(item1); this.removeRelationshipItemsFromCache(item2); }) @@ -115,11 +114,12 @@ export class RelationshipService extends DataService { private removeRelationshipItemsFromCache(item) { this.objectCache.remove(item.self); this.requestService.removeByHrefSubstring(item.self); - this.objectCache.hasBySelfLinkObservable(item.self).pipe( - tap((exists) => console.log('exists: ', exists, 'uuid', item.uuid)), - filter((exists) => !exists), + combineLatest( + this.objectCache.hasBySelfLinkObservable(item.self), + this.requestService.hasByHrefObservable(item.self) + ).pipe( + filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC), take(1), - tap((exists) => console.log('still exists: ', exists, 'uuid', item.uuid)), switchMap(() => this.itemService.findByHref(item.self).pipe(take(1))) ).subscribe(); } @@ -254,11 +254,6 @@ export class RelationshipService extends DataService { getRelationshipByItemsAndLabel(item1: Item, item2: Item, label: string): Observable { - 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) .pipe( mergeMap((relationships: Relationship[]) => { @@ -273,7 +268,6 @@ export class RelationshipService extends DataService { })) }), map((relationships: Relationship[]) => relationships.find((relationship => hasValue(relationship)))), - tap((relationships) => console.log(relationships)), ) }