diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index a66d13b3b..acceaa6ce 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -20,7 +20,6 @@ export class FileDataModel { allAnnotations: AnnotationWrapper[] = []; readonly hasChangeLog$ = new BehaviorSubject(false); missingTypes = new Set(); - _textHighlightResponse: TextHighlightResponse; textHighlightAnnotations: AnnotationWrapper[] = []; constructor( @@ -43,8 +42,6 @@ export class FileDataModel { } set textHighlights(textHighlightResponse: TextHighlightResponse) { - this._textHighlightResponse = textHighlightResponse; - const highlights = []; // eslint-disable-next-line @typescript-eslint/no-unsafe-argument for (const color of Object.keys(textHighlightResponse.redactionPerColor)) { @@ -60,6 +57,7 @@ export class FileDataModel { if (viewMode === 'TEXT_HIGHLIGHTS') { return this.textHighlightAnnotations; } + return this.allAnnotations.filter(annotation => { if (viewMode === 'STANDARD') { return !annotation.isChangeLogRemoved; diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts index 1f34c3d9e..2d1b23d5a 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts @@ -24,7 +24,6 @@ import { shareDistinctLast, shareLast, } from '@iqser/common-ui'; -import { PermissionsService } from '@services/permissions.service'; import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; import { map, tap } from 'rxjs/operators'; import { File } from '@red/domain'; @@ -35,7 +34,6 @@ import { SkippedService } from '../../services/skipped.service'; import { FilePreviewStateService } from '../../services/file-preview-state.service'; import { ViewModeService } from '../../services/view-mode.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { PdfViewer } from '../../services/pdf-viewer.service'; const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape']; const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; @@ -72,7 +70,6 @@ export class FileWorkloadComponent { @ViewChild('quickNavigation') private readonly _quickNavigationElement: ElementRef; constructor( - private readonly _pdf: PdfViewer, readonly filterService: FilterService, readonly skippedService: SkippedService, readonly state: FilePreviewStateService, @@ -81,7 +78,6 @@ export class FileWorkloadComponent { readonly excludedPagesService: ExcludedPagesService, private readonly _viewModeService: ViewModeService, private readonly _changeDetectorRef: ChangeDetectorRef, - private readonly _permissionsService: PermissionsService, private readonly _annotationProcessingService: AnnotationProcessingService, ) { this.displayedAnnotations$ = this._displayedAnnotations$; diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts index 8ea44bdff..4c5ee0e5a 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/pdf-viewer/pdf-viewer.component.ts @@ -684,7 +684,9 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha return entry; } - private _loadDocument(blob: Blob, file: File) { + private async _loadDocument(blob: Blob, file: File) { + const document = await this.instance.Core.documentViewer.getDocument()?.getPDFDoc(); + await document?.lock(); this.instance.UI.loadDocument(blob, { filename: file?.filename ?? 'document.pdf' }); this._pageRotationService.clearRotationsHideActions(); } 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 5c826b35f..17a4b3d00 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 @@ -486,7 +486,12 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni return; } - await clearStamps(pdfDoc, this._pdf.PDFNet, allPages); + try { + await clearStamps(pdfDoc, this._pdf.PDFNet, allPages); + } catch (e) { + console.log('Error clearing stamps: ', e); + return; + } if (this._viewModeService.isRedacted) { const dossier = await this.stateService.dossier; diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/services/annotation-draw.service.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/services/annotation-draw.service.ts index 31c83eef2..63a85538a 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/services/annotation-draw.service.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/services/annotation-draw.service.ts @@ -86,10 +86,13 @@ export class AnnotationDrawService { } private async _drawAnnotations(annotationWrappers: AnnotationWrapper[]) { - if (!this._pdf.ready) { + const document = await this._pdf.documentViewer.getDocument()?.getPDFDoc(); + if (!this._pdf.ready || !document) { return; } + await document.lock(); + const annotations = annotationWrappers.map(annotation => this._computeAnnotation(annotation)).filter(a => !!a); this._pdf.instance.Core.annotationManager.addAnnotations(annotations, { imported: true }); await this._pdf.instance.Core.annotationManager.drawAnnotationsFromList(annotations);