diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts index 5645d015fe..60a098d875 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts @@ -204,11 +204,14 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { }); if (this.displayPredictions) { - this.predictionService.predictionStatusUpdated$.pipe(takeUntil(this.onDestroy$)).subscribe(({key, previousValue}) => { - this.cardViewContentUpdateService.onPredictionStatusChanged([{key, previousValue}]); - this.nodesApiService.getNode(this.node.id).subscribe((node) => { - Object.assign(this.node, node); - }); + this.predictionService.predictionStatusUpdated$.pipe(takeUntil(this.onDestroy$)).subscribe(({ key, previousValue }) => { + this.cardViewContentUpdateService.onPredictionStatusChanged([{ key, previousValue }]); + this.nodesApiService + .getNode(this.node.id) + .pipe(takeUntil(this.onDestroy$)) + .subscribe((node) => { + Object.assign(this.node, node); + }); }); } @@ -423,7 +426,9 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { .subscribe((result: any) => { if (result) { if (this.displayPredictions) { - this.cardViewContentUpdateService.onPredictionStatusChanged(Object.keys(this.changedProperties['properties']).map(key => ({key}))); + this.cardViewContentUpdateService.onPredictionStatusChanged( + Object.keys(this.changedProperties['properties']).map((key) => ({ key })) + ); } this.updateUndefinedNodeProperties(result.updatedNode); if (this.hasContentTypeChanged(this.changedProperties)) { @@ -471,22 +476,34 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { requests['predictions'] = this.loadPredictionsForNode(this.node.id); } - forkJoin(requests).subscribe(({ predictions, properties, groupedProperties }: ({ predictions: Prediction[]; properties: CardViewItem[]; groupedProperties: CardViewGroup[] })) => { - if (loadBasicProps && properties) { - this.basicProperties$ = predictions - ? of(properties.map(property => this.mapPredictionsToProperty(property, predictions))) - : of(properties); - } + forkJoin(requests).subscribe( + ({ + predictions, + properties, + groupedProperties + }: { + predictions: Prediction[]; + properties: CardViewItem[]; + groupedProperties: CardViewGroup[]; + }) => { + if (loadBasicProps && properties) { + this.basicProperties$ = predictions + ? of(properties.map((property) => this.mapPredictionsToProperty(property, predictions))) + : of(properties); + } - if (loadGroupedProps && groupedProperties) { - this.groupedProperties$ = predictions - ? of(groupedProperties.map(group => { - group.properties = group.properties.map(property => this.mapPredictionsToProperty(property, predictions)); - return group; - })) - : of(groupedProperties); + if (loadGroupedProps && groupedProperties) { + this.groupedProperties$ = predictions + ? of( + groupedProperties.map((group) => { + group.properties = group.properties.map((property) => this.mapPredictionsToProperty(property, predictions)); + return group; + }) + ) + : of(groupedProperties); + } } - }); + ); if (this.displayTags && loadTags) { this.loadTagsForNode(node.id); @@ -585,15 +602,20 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { private mapPredictionsToProperty(property: CardViewItem, predictions: Prediction[]): CardViewItem { const propertyKey = property.key.split('.')[1]; - const filteredPrediction = predictions.find(prediction => prediction.property === propertyKey && prediction.reviewStatus === ReviewStatus.UNREVIEWED && prediction.predictionValue === property.value); + const filteredPrediction = predictions.find( + (prediction) => + prediction.property === propertyKey && + prediction.reviewStatus === ReviewStatus.UNREVIEWED && + prediction.predictionValue === property.value + ); property.prediction = filteredPrediction || null; return property; } private loadPredictionsForNode(nodeId: string): Observable { - return this.predictionService.getPredictions(nodeId).pipe( - map(predictionPaging => predictionPaging.list.entries.map(predictionEntry => predictionEntry.entry)) - ); + return this.predictionService + .getPredictions(nodeId) + .pipe(map((predictionPaging) => predictionPaging.list.entries.map((predictionEntry) => predictionEntry.entry))); } }