From da48b72eb761e0f0e41a984db20cbac80e82689f Mon Sep 17 00:00:00 2001 From: Irmantas Kaukas Date: Mon, 18 Mar 2024 13:52:04 +0100 Subject: [PATCH] fix: resource item properties update (DEV-3393) (#1512) --- .../resource/properties/properties.component.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/dsp-app/src/app/workspace/resource/properties/properties.component.ts b/apps/dsp-app/src/app/workspace/resource/properties/properties.component.ts index d28bed6650..7681b43dc3 100644 --- a/apps/dsp-app/src/app/workspace/resource/properties/properties.component.ts +++ b/apps/dsp-app/src/app/workspace/resource/properties/properties.component.ts @@ -53,7 +53,7 @@ import { } from '@dasch-swiss/vre/shared/app-state'; import { Actions, Store, ofActionSuccessful } from '@ngxs/store'; import { Observable, Subject, Subscription, forkJoin } from 'rxjs'; -import { map, take, takeUntil, takeWhile } from 'rxjs/operators'; +import { map, takeUntil, takeWhile } from 'rxjs/operators'; import { ConfirmationWithComment, DialogComponent } from '../../../main/dialog/dialog.component'; import { DspResource } from '../dsp-resource'; import { RepresentationConstants } from '../representation/file-representation'; @@ -258,7 +258,7 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy { ]); this._actions$ .pipe(ofActionSuccessful(GetAttachedUserAction)) - .pipe(take(1)) + .pipe(takeUntil(this.ngUnsubscribe)) .subscribe(() => { const attachedUsers = this._store.selectSnapshot(ResourceSelectors.attachedUsers); this.user = attachedUsers[this.resource.res.id].value.find(u => u.id === this.resource.res.attachedToUser); @@ -274,6 +274,9 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy { if (this.valueOperationEventSubscriptions !== undefined) { this.valueOperationEventSubscriptions.forEach(sub => sub.unsubscribe()); } + + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); } trackByFn = (index: number, item: ReadResource) => `${index}-${item.id}`; @@ -454,6 +457,10 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy { * @param valueToAdd the value to add to the end of the values array of the filtered property */ addValueToResource(valueToAdd: ReadValue): void { + if (!valueToAdd.id.includes(this.resource.res.id)) { + return; + } + if (this.resource.resProps) { this.resource.resProps .filter(propInfoValueArray => propInfoValueArray.propDef.id === valueToAdd.property) // filter to the correct property