fixed unnecesary redraws

This commit is contained in:
Timo Bejan 2020-11-11 12:36:28 +02:00
parent 86de4f2040
commit d323bbcb96
2 changed files with 9 additions and 6 deletions

View File

@ -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) {

View File

@ -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);
});
}