From ccd008666e0e137af6f3e3652970eaee24b9dfaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Fri, 27 Sep 2024 16:38:58 +0300 Subject: [PATCH] RED-10034: Removed unnecessary draw call? --- .../file-preview/file-preview-screen.component.ts | 10 +++++----- .../pdf-viewer/services/annotation-draw.service.ts | 2 +- .../services/annotation-manager.service.ts | 14 ++++---------- .../src/app/services/files/entity-log.service.ts | 8 ++------ 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 7701d687c..2e7fbdfd4 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -100,13 +100,13 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni readonly roles = Roles; readonly fileId = this.state.fileId; readonly dossierId = this.state.dossierId; + protected readonly isDocumine = getConfig().IS_DOCUMINE; @ViewChild('annotationFilterTemplate', { read: TemplateRef, static: false, }) private readonly _filterTemplate: TemplateRef; #loadAllAnnotationsEnabled = false; - protected readonly isDocumine = getConfig().IS_DOCUMINE; constructor( readonly pdf: PdfViewer, @@ -447,11 +447,11 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this._annotationManager.delete(annotationsToDelete); } - drawChangedAnnotations(oldAnnotations: AnnotationWrapper[], newAnnotations: AnnotationWrapper[]) { + async drawChangedAnnotations(oldAnnotations: AnnotationWrapper[], newAnnotations: AnnotationWrapper[]): Promise { const annotationsToDraw = this.#getAnnotationsToDraw(oldAnnotations, newAnnotations); this._logger.info('[ANNOTATIONS] To draw: ', annotationsToDraw); this._annotationManager.delete(annotationsToDraw); - return this.#cleanupAndRedrawAnnotations(annotationsToDraw); + await this.#cleanupAndRedrawAnnotations(annotationsToDraw); } async #openRedactTextDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) { @@ -702,7 +702,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this._errorService.set(error); } - #cleanupAndRedrawAnnotations(newAnnotations: List) { + async #cleanupAndRedrawAnnotations(newAnnotations: List): Promise { if (!newAnnotations.length) { return undefined; } @@ -716,7 +716,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni }, 100); } - return this._annotationDrawService.draw(newAnnotations, this._skippedService.hideSkipped(), this.state.dossierTemplateId); + await this._annotationDrawService.draw(newAnnotations, this._skippedService.hideSkipped(), this.state.dossierTemplateId); } #handleDeltaAnnotationFilters(currentFilters: NestedFilter[]) { diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts index b888686b6..c71ac171b 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { List } from '@iqser/common-ui/lib/utils'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { Core } from '@pdftron/webviewer'; -import { IRectangle, ISectionRectangle, IPoint, SuperTypes } from '@red/domain'; +import { IPoint, IRectangle, ISectionRectangle, SuperTypes } from '@red/domain'; import { DefaultColorsService } from '@services/entity-services/default-colors.service'; import { hexToRgb } from '@utils/functions'; import { BoundingBox, Table } from '../../file-preview/services/tables.service'; diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts index a2457e199..201d3560c 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts @@ -19,14 +19,14 @@ const MOVE_OPTION = 'move'; @Injectable() export class REDAnnotationManager { + resizingAnnotationId?: string = undefined; + annotationHasBeenResized?: boolean = false; readonly #hidden = signal(new Set()); + readonly hidden = this.#hidden.asReadonly(); #manager: AnnotationManager; readonly #logger = inject(NGXLogger); readonly #annotationSelected$ = new Subject<[Annotation[], string]>(); readonly annotationSelected$ = this.#annotationSelected$.asObservable(); - resizingAnnotationId?: string = undefined; - annotationHasBeenResized?: boolean = false; - readonly hidden = this.#hidden.asReadonly(); get selected() { return this.#manager.getSelectedAnnotations(); @@ -128,21 +128,15 @@ export class REDAnnotationManager { annotations.forEach(annotation => this.#manager.redrawAnnotation(annotation)); } - add(annotations: Annotation | Annotation[]) { + async add(annotations: Annotation | Annotation[]): Promise { try { annotations = asList(annotations); this.#manager.addAnnotations(annotations, { imported: true }); - return this.#manager.drawAnnotationsFromList(annotations); } catch (e) { console.log(e); } } - showHidden() { - const hidden = this.#getByIds([...this.hidden().values()]); - this.show(hidden); - } - #listenForAnnotationSelected() { this.#manager.addEventListener('annotationSelected', async (annotations: Annotation[], action: string) => { this.#logger.info('[PDF] Annotation selected: ', annotations, action); diff --git a/apps/red-ui/src/app/services/files/entity-log.service.ts b/apps/red-ui/src/app/services/files/entity-log.service.ts index dbc05ea4e..d7287d40c 100644 --- a/apps/red-ui/src/app/services/files/entity-log.service.ts +++ b/apps/red-ui/src/app/services/files/entity-log.service.ts @@ -1,6 +1,6 @@ import { inject, Injectable } from '@angular/core'; -import { GenericService, isIqserDevMode, Toaster } from '@iqser/common-ui'; -import { EntryStates, IEntityLog, IEntityLogEntry, ISectionGrid } from '@red/domain'; +import { GenericService, Toaster } from '@iqser/common-ui'; +import { EntryStates, IEntityLog, IEntityLogEntry } from '@red/domain'; import { firstValueFrom, of } from 'rxjs'; import { catchError } from 'rxjs/operators'; @@ -20,10 +20,6 @@ export class EntityLogService extends GenericService { return entityLog; } - getSectionGrid(dossierId: string, fileId: string) { - return this._getOne([dossierId, fileId], 'sectionGrid'); - } - #filterInvalidEntries(entityLogEntry: IEntityLogEntry[]) { return entityLogEntry.filter(entry => { entry.positions = entry.positions?.filter(p => !!p.rectangle?.length);