From d323bbcb9644da69fe8b3d6f3081ad67163e25f7 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Wed, 11 Nov 2020 12:36:28 +0200 Subject: [PATCH] fixed unnecesary redraws --- .../file-preview-screen.component.ts | 10 ++++++---- .../screens/file/service/annotation-draw.service.ts | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts index e7aa28799..889ac97f3 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts @@ -165,7 +165,9 @@ export class FilePreviewScreenComponent implements OnInit { openManualRedactionDialog($event: ManualRedactionEntryWrapper) { this.ngZone.run(() => { this._dialogRef = this._dialogService.openManualRedactionDialog($event, (response: ManualAnnotationResponse) => { - this._cleanupAndRedrawManualAnnotations(); + if (response?.annotationId) { + this._cleanupAndRedrawManualAnnotations(response.annotationId); + } }); }); } @@ -366,13 +368,13 @@ export class FilePreviewScreenComponent implements OnInit { } } - private _cleanupAndRedrawManualAnnotations(singleAnnotation?: AnnotationWrapper) { + private _cleanupAndRedrawManualAnnotations(annotationIdToDraw?: string) { this._fileDownloadService.loadActiveFileManualAnnotations().subscribe((manualRedactions) => { this.fileData.manualRedactions = manualRedactions; this._rebuildFilters(); this._annotationDrawService.drawAnnotations( this.instance, - this.annotations.filter((item) => (singleAnnotation ? singleAnnotation.id === item.id && singleAnnotation.shouldDraw : item.shouldDraw)) + this.annotations.filter((item) => (annotationIdToDraw ? item.id === annotationIdToDraw && item.shouldDraw : item.shouldDraw)) ); }); } @@ -382,7 +384,7 @@ export class FilePreviewScreenComponent implements OnInit { if (viewerAnnotation) { this.activeViewer.annotManager.deleteAnnotation(viewerAnnotation, true, true); } - this._cleanupAndRedrawManualAnnotations(annotation); + this._cleanupAndRedrawManualAnnotations(annotation.id); } async fileActionPerformed(action: string) { diff --git a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts index d51225e7a..283f72a04 100644 --- a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts +++ b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts @@ -12,8 +12,9 @@ export class AnnotationDrawService { constructor(private readonly _appStateService: AppStateService) {} public drawAnnotations(activeViewer: WebViewerInstance, annotationWrappers: AnnotationWrapper[]) { - annotationWrappers.forEach((mre) => { - this.drawAnnotation(activeViewer, mre); + annotationWrappers.forEach((annotation) => { + console.log('draw', annotation); + this.drawAnnotation(activeViewer, annotation); }); }