From c498065338e5ddc85fe64d87f9ed957a6cc48d70 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Thu, 9 Dec 2021 17:40:59 +0200 Subject: [PATCH] fix RED-2977 --- .../file-preview-screen.component.ts | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index b9661a068..e802c64a7 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -404,7 +404,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni async viewerReady($event: WebViewerInstance) { this._instance = $event; await this._stampPDF(); - await this._cleanupAndRedrawManualAnnotations$().toPromise(); + await this._cleanupAndRedrawManualAnnotations(); this._setExcludedPageStyles(); this._instance.Core.documentViewer.addEventListener('pageComplete', () => { @@ -554,7 +554,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni await this._loadFileData(file, !this._reloadFileOnReanalysis); this._reloadFileOnReanalysis = false; this._loadingService.stop(); - await this._cleanupAndRedrawManualAnnotations$().toPromise(); + await this._cleanupAndRedrawManualAnnotations(); }); } @@ -584,13 +584,19 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this._workloadComponent?.scrollAnnotations(); } - /* Get the documentElement () to display the page in fullscreen */ + private async _cleanupAndRedrawManualAnnotations() { + const currentAnnotations = this.annotations; + this.fileData.redactionLog = await this._fileDownloadService.loadRedactionLogFor(this.dossierId, this.fileId).toPromise(); + this.rebuildFilters(); - private _cleanupAndRedrawManualAnnotations$() { - return this._fileDownloadService.loadRedactionLogFor(this.dossierId, this.fileId).pipe( - tap(redactionLog => (this.fileData.redactionLog = redactionLog)), - switchMap(() => this._redrawAnnotations()), - ); + if (this.viewModeService.viewMode === 'STANDARD') { + currentAnnotations.forEach(annotation => { + this._findAndDeleteAnnotation(annotation.id); + }); + const newAnnotations = this.annotations; + this._handleDeltaAnnotationFilters(currentAnnotations, newAnnotations); + await this._redrawAnnotations(newAnnotations); + } } private async _cleanupAndRedrawManualAnnotationsForEntirePage(page: number) { @@ -643,7 +649,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni } private _findAndDeleteAnnotation(id: string) { - const viewerAnnotation = this._instance.Core.annotationManager.getAnnotationById(id); + const viewerAnnotation = this._instance?.Core.annotationManager.getAnnotationById(id); if (viewerAnnotation) { this._instance.Core.annotationManager.deleteAnnotation(viewerAnnotation, { imported: true,